开发者

How to get exact RGB values for 24-bit image in .NET Compact Framework?

开发者 https://www.devze.com 2023-01-07 16:45 出处:网络
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

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号