Click here to Skip to main content
13,594,948 members
Rate this:
Please Sign up or sign in to vote.
See more:
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);

Would this give me the accurate pixel values? Independent of palette, if at all it is necessary. Thanks in regards,
Posted 18-Feb-13 20:06pm

1 solution

Rate this: bad
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.

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 | Cookies | Terms of Service
Web04-2016 | 2.8.180621.3 | Last Updated 3 Mar 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

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