Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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:

C++
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)


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

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900