GetHBitmapFromGdPictureImage always returns 32bit image

Discussions about image processing and document imaging.
Post Reply
PeterWolf
Posts: 1
Joined: Thu Dec 18, 2014 11:09 am

GetHBitmapFromGdPictureImage always returns 32bit image

Post by PeterWolf » Thu Dec 18, 2014 11:52 am

Hi,

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));
The output of the debug print indicates that after the GetHBitmapFromGdPictureImage step the resulting HBitmap image has a 32bit color depth.

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.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: GetHBitmapFromGdPictureImage always returns 32bit image

Post by Loïc » Sun Dec 21, 2014 7:22 pm

Hello Peter,

You're right this method always produces 32-bit bitmap. If you need to preserve the initial pixel format you should consider to use the GetDibFromGdPictureImage() method that produces a device independent bitmap. See: http://msdn.microsoft.com/en-us/library ... s.85).aspx

Please let me know if you need further information.

With best regards and Merry Christmas,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest