I use the following code on an tiff with 1 bit color depth, i.e. one bit per pixel.
Code: Select all
var tiff = new GdPictureImaging()
var id = tiff.CreateGdPictureImageFromFile(file);
var ptr = tiff.GetHBitmapFromGdPictureImage(id);
var id2 = tiff.CreateGdPictureImageFromHBitmap(ptr);
Debug.Print(tiff.GetBitDepth(id) + " " + tiff.GetBitDepth(id2));
I am not an expert regarding HBitmaps. Is this behavior a bug or on purpose? Is there any way to create an HBitmap with GdPicture that preserves the color depth of the original image?
best, Peter
PS: As far as I can tell, this behavior is independent of the original image. It does not matter whether its a 24bpp, 8bpp or 32bpp, the resulting HBitmap is always 32bpp.