views:

195

answers:

4

I'd like to use the image property tag constants defined in GDI+ from .NET.

I wonder whether these constant values (e.g. PropertyTagGpsVer constant) are exposed in any of the Base Class Library?

I have tried looking around System.Drawing.Imaging namespace to no avail.

A: 

You're looking for the System.Drawing.Imaging.PropertyItem class. See a description and an example on MSDN

Adam Robinson
I'm looking for the constant values for the ID property in PropertyItem.
Adrian Godong
+4  A: 

No, they are not.

Enumeration of the tags: http://msdn.microsoft.com/en-us/library/ms534417%28VS.85%29.aspx Long description of the tags: http://msdn.microsoft.com/en-us/library/ms534416%28VS.85%29.aspx

I ended up copying and pasting most of these two pages into code in order to do what you want: have a set of constants. You'll need to implement a set of PropertyItems by name and pre-populate them with the id, length, and type of the PropertyItem.

The other way to do it is t just choose the constants you need and implement them.

Oplopanax
+1  A: 

Here is a complete example of the kind of code you want to use: Code Sample

i tested it, it compiled ran and here's an example of the data it returned (ugly but proves the concept.)

RESULT:

Image: \Desktop\SouthSisterPanorama.jpg
Width= 5861, Height= 625
PixelFormat = Format24bppRgb
Dumping 2 property items:PropertyTagLuminanceTable 
 Type:PropertyTagTypeShort
 Length:128
 Values:
 08 00 06 00 05 00 08 00 0C 00 14 00 1A 00 1F 00  ................
 06 00 06 00 07 00 0A 00 0D 00 1D 00 1E 00 1C 00  ................
 07 00 07 00 08 00 0C 00 14 00 1D 00 23 00 1C 00  ............#...
 07 00 09 00 0B 00 0F 00 1A 00 2C 00 28 00 1F 00  ..........,.(...
 09 00 0B 00 13 00 1C 00 22 00 37 00 34 00 27 00  ........".7.4.'.
 0C 00 12 00 1C 00 20 00 29 00 34 00 39 00 2E 00  ...... .).4.9...
 19 00 20 00 27 00 2C 00 34 00 3D 00 3C 00 33 00  .. .'.,.4.=.<.3.
 24 00 2E 00 30 00 31 00 38 00 32 00 34 00 32 00  $...0.1.8.2.4.2.

PropertyTagChrominanceTable 
 Type:PropertyTagTypeShort
 Length:128
 Values:
 09 00 09 00 0C 00 18 00 32 00 32 00 32 00 32 00  ........2.2.2.2.
 09 00 0B 00 0D 00 21 00 32 00 32 00 32 00 32 00  ......!.2.2.2.2.
 0C 00 0D 00 1C 00 32 00 32 00 32 00 32 00 32 00  ......2.2.2.2.2.
 18 00 21 00 32 00 32 00 32 00 32 00 32 00 32 00  ..!.2.2.2.2.2.2.
 32 00 32 00 32 00 32 00 32 00 32 00 32 00 32 00  2.2.2.2.2.2.2.2.
 32 00 32 00 32 00 32 00 32 00 32 00 32 00 32 00  2.2.2.2.2.2.2.2.
 32 00 32 00 32 00 32 00 32 00 32 00 32 00 32 00  2.2.2.2.2.2.2.2.
 32 00 32 00 32 00 32 00 32 00 32 00 32 00 32 00  2.2.2.2.2.2.2.2.
Paul Sasik
I was thinking something more native instead of a list maintained by an individual. EXIF standard is always evolving, and having a native or automatically updated is much preferable. Good link though, +1.
Adrian Godong
i searched the 2.0, 3.0 and 3.5 class libraries for anything matching *PropertyTag* and came up empty. So, there isn't anything native, at least not in the current frameworks. i doubt it'll happen too. i've been waiting for a "native" .Net wrapper to the Win32 API since 1.0 and there's no sign of it. We're still relegated to having to do DLL imports and IntPtrs to basic Win32 APIs like SendMessage. If you put something together, publish it on SourceForge or CodePlex and make it a standard maintained by many!
Paul Sasik
A: 

If you have the Microsoft SDKs, you can find all the constants in a C header file named GdiPlusImaging.h

It would be simple enough to include the header in a C project, but you'd have to do some tweaking to put them all into enumerations.

Fred