I'm searching for a .NET wrapper for GFL SDK. Does somebody already implement such one?
Actually I need only wrapper for gflLoadEXIF() function.
But I've some troubles with marshaling of data. What do I wrong?
Code: Select all
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct GFL_EXIF_ENTRY
{
/// <summary>
/// Directory of the tag.
/// EXIF_MAIN_IFD 0 Main
/// EXIF_IFD_0 2 IFD 0 or Camera IFD
/// EXIF_INTEROPERABILITY_IFD 4 Interoperability IFD
/// EXIF_IFD_THUMBNAIL 8 Thumbnail IFD
/// EXIF_GPS_IFD 16 GPS IFD
/// EXIF_MAKERNOTE_IFD 32 Makernote IFD (Canon, Olympus, Minolta, Fuji, Nikon, Casio camera supported)
/// </summary>
public uint Flag;
/// <summary>
/// Tag value
/// </summary>
public uint Tag;
/// <summary>
/// Pointer to a null-terminated string that contains the label of the tag.
/// </summary>
public IntPtr Name;
/// <summary>
/// Pointer to a null-terminated string that contains the value of the tag
/// </summary>
public IntPtr Value;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct GFL_EXIF_DATA
{
public GFL_EXIF_ENTRY[] ItemsList;
public uint NumberOfItems;
}
...
[DllImport("libgfl290.dll", EntryPoint ="gflLibraryInit", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall )]
public static extern GFL_ERROR gflLibraryInit();
[DllImport("libgfl290.dll", EntryPoint = "gflLoadEXIF", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern IntPtr gflLoadEXIF(StringBuilder fileName, uint flags);
...
StringBuilder name = new StringBuilder(@"F:\Photo\CN0340.JPG");
GFL_EXIF_DATA ExifStruct;
IntPtr pExif = gflLoadEXIF(name, 1);
ExifStruct = (GFL_EXIF_DATA)Marshal.PtrToStructure(pExif, typeof(GFL_EXIF_DATA));
Do you have some tip for me? What do I wrong?