Click here to Skip to main content
12,354,349 members (72,197 online)
Rate this:
 
Please Sign up or sign in to vote.
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 3 Mar 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100