I have a 24 bit BMP image, but when I load it on my Pocket PC using Bitmap object and do GetPixel, it returns me开发者_Go百科 slightly wrong RGB values. I guess it converts it to 16 bit on the fly. I get the same results when using LockBits and working with the bitmap data directly. Is there any way of getting exact RGB values for given pixel of the 24 bit BMP in .NET Compact Framework?
Thanks in advance.
Humm, interesting!
I'm not sure about what I'll say but if it has 16bit color, it should have a color palette to represent the full true color (32 bits). In this case the 'color' you get (the 16 bit pixel value) is the index of the color palette. The Bitmap object has a Palette property, maybe it worth to take a look, run some tests and see if what I'm saying makes sense!
Regards
Bitmap class
Palette property
My bet is that however you've loaded the Bitmap got it translated to a DDB and the driver is set to use 24-bit color and that's what you end up with. If you want to maintain 32-bit color, you need to use a DIB. For the Compact Framework that means loading the image with the stream constructor (see this blog entry for more on DDB/DIB in the CF).
精彩评论