is there a way to get the pixel color that is under the mouse?

i heard of ways where i can turn it into bmp's a.. but even then i can't get the color of the pixel under mouse.. D:

i just need a thing to make it get the pixel under mouse .. i know how to extract RGB values from the pixel then :)

well if any1 can tell me
thnx :D

Recommended Answers

All 2 Replies

Very simple using the Windows API, here's an example:

COLORREF GetMousePixel() {
  HDC hdc = GetDC( NULL );
  POINT mp; // Mouse point
  GetCursorPos( &mp );
  COLORREF pixel = GetPixel( hdc, mp.x, mp.y );
  return pixel;
}

You can then use GetRValue, GetGValue, and GetBValue to get the individual colours from the pixel.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.