如何在 .NET Compact Framework 中获取 24 位图像的精确 RGB 值?

发布于 2024-09-10 03:17:33 字数 208 浏览 1 评论 0原文

我有一个 24 位 BMP 图像,但是当我使用 Bitmap 对象将其加载到 Pocket PC 上并执行 GetPixel 时,它返回的 RGB 值略有错误。我猜它会即时将其转换为 16 位。当使用 LockBits 并直接处理位图数据时,我得到了相同的结果。有没有办法获得 .NET Compact Framework 中 24 位 BMP 给定像素的精确 RGB 值?

提前致谢。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

羁〃客ぐ 2024-09-17 03:17:33

嗯,有趣!

我不确定我会说什么,但如果它有 16 位颜色,它应该有一个调色板来表示完整的真实颜色(32 位)。在这种情况下,您获得的“颜色”(16 位像素值)是调色板的索引。 Bitmap 对象有一个 Palette 属性,也许值得一看,运行一些测试,看看我所说的是否有意义!

问候

位图类

调色板属性

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

灼痛 2024-09-17 03:17:33

我敢打赌,无论您如何加载位图,都会将其转换为 DDB,并且驱动程序设置为使用 24 位颜色,这就是您最终得到的结果。如果要保持32位颜色,则需要使用DIB。对于 Compact Framework,这意味着使用流构造函数加载图像(请参阅此有关 CF 中 DDB/DIB 的更多信息的博客文章)。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文