private static bool IsDib(IntPtr dibBitmap) { // a quick check not guaranteed correct, // compare first byte to size of struct (which is also the first field) var test = Marshal.ReadInt32(dibBitmap); // should be 40 return(test == BITMAPINFOHEADER.GetByteSize()); }
// this is modified from twain cs sample // http://sourceforge.net/projects/twainforcsharp/?source=typ_redirect public static bool IsDib(IntPtr data) { // a quick check not guaranteed correct, // compare first 2 bytes to size of struct (which is also the first field) var test = Marshal.ReadInt16(data); // should be 40 return(test == BITMAPINFOHEADER.GetByteSize()); }