Click here to Skip to main content
Sign Up to vote bad
good
See more: C++MFC
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)
 
Would this give me the accurate pixel values? Independent of palette, if at all it is necessary. Thanks in regards,
-DJ
Posted 18-Feb-13 20:06pm


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

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 6,959
1 Prasad_Kulkarni 3,671
2 OriginalGriff 3,359
3 _Amy 3,332
4 CPallini 2,925


Advertise | Privacy | Mobile
Web01 | 2.6.130617.1 | Last Updated 3 Mar 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid