如何读取独立于显示的原始位图值 [英] how to read a raw bitmap value independent of display

查看:66
本文介绍了如何读取独立于显示的原始位图值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在学习Visual C ++的绳索。我想加载位图文件(DIB),找出单个原始像素值(RGB)和处理。我理解位图,调色板等我试过:



Hi,
I am learning the ropes of Visual C++. I want to load a bitmap file(DIB), find out individual raw pixel values(RGB) and process. I am understanding bitmap,palettes etc. I have tried:

if (nColors > 256)
    m_palette.CreateHalftonePalette (&dc);

   pOldPalette = pDC->SelectPalette (m_palette, FALSE);
   pDC->RealizePalette ();
   CDC memDC;
   memDC.CreateCompatibleDC (pDC);
   CBitmap* pOldBitmap = memDC.SelectObject (pBitmap);
   memDC.GetPixel(x,y)





这会给我准确的像素值吗?独立于调色板,如果有必要的话。谢谢,

-DJ



Would this give me the accurate pixel values? Independent of palette, if at all it is necessary. Thanks in regards,
-DJ

推荐答案

GetPixel()将返回COLORREF数据类型。然后,您可以使用以下公式获得3个值(红色,绿色和蓝色):

低位字节将包含红色值,第二个字节用于绿色,第三个字节包含蓝色的值。
GetPixel() will return a COLORREF data type. You can then get 3 values (Red, Green, and Blue) using the following formula:
The low-order byte will contain the Red value, the second byte is for green, and the third byte contains a value for blue.


这篇关于如何读取独立于显示的原始位图值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆