Calling .Net - Image orientation

Discussion forum about all things Team Developer 7.x
-tommi
Finland
Posts: 27
Joined: 03 May 2017, 08:00
Location: Finland

Calling .Net - Image orientation

Post by -tommi » 05 Nov 2019, 11:51

How can I get the value of image orientation via .Net assembly?

Sample code for getting orientation in .Net:

Code: Select all

 using (var image = System.Drawing.Image.FromFile(fileName))
    {
        foreach (var prop in image.PropertyItems)
        {
            if (prop.Id == 0x112)
            {
                if (prop.Value[0] == 6)
                    rotate = 90;
                if (prop.Value[0] == 8)
                    rotate = -90;
                if (prop.Value[0] == 3)
                    rotate = 180;
                prop.Value[0] = 1;
            }
        }
    }
TD code:

Code: Select all


Class: System_Drawing_Imaging_PropertyItem
	Inherits: System_Object
	Instance Variables:
	Functions:
		get_Id
			Returns: Integer 
			Parameters
		set_Id
			Returns: NoneVoid 
			Parameters
				Integer
		get_Len
			Returns: Integer 
			Parameters
		set_Len
			Returns: NoneVoid 
			Parameters
				Integer
		get_Type
			Returns: Short 
			Parameters
		set_Type
			Returns: NoneVoid 
			Parameters
				Short
		set_Value
			Returns: NoneVoid 
			Parameters
				Binary

Actual Code:

Set oImage = System_Drawing_Image_FromFile(strImage)
Set oPropertyItem = oImage.GetPropertyItem( 0x112 )
Set nLen = oPropertyItem.get_Len
Set nType = oPropertyItem.get_Type
I can get the Type and Len values in TD, but how can I get the actual value of Value[0]?
There is function: set_Value, but no get_Value.

Holger
Germany
Posts: 26
Joined: 07 Mar 2018, 13:43
Location: Oberkirch, Germany

Re: Calling .Net - Image orientation

Post by Holger » 06 Nov 2019, 10:33

Hello Tommi,

unfortunately, you can't get Array Properties from .NET to Centura.
I wrote in those cases a wrapper class in C#. As Parameter the index of the array you want to ask and as return value the value you want to know, either if it is a whole class or just a number as in your case.

Regards,
Holger

-tommi
Finland
Posts: 27
Joined: 03 May 2017, 08:00
Location: Finland

Re: Calling .Net - Image orientation

Post by -tommi » 06 Nov 2019, 11:58

Hi Holger.

Not what I was looking for, but thank you.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests