[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

Retrieving an individual pixel color from a bitmap.

I am working with an application in which the bitmaps need to be drawn transparently (one color is not drawn) so that they will match whatever background they are on.  I have the transparency functionality working and now would like to modify it to select one of the corner pixels to be the color that is removed.  Currently I am hard coding the value of the color I don't want drawn.  I am looking for a method of retrieving a pixel color from a bitmap given a handle to the bitmap.
1 Solution
// Given HBITMAP hBmp, get clr

HDC hMemDC = ::CreateCompatibleDC(NULL);

HBITMAP hOldBmp = ::SelectObject(hMemDC, hBmp);

COLORREF clr = ::GetPixel(hMemDC, x, y);

::SelectObject(hMemDC, hOldBmp);

themaskAuthor Commented:

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now