a program displays the blue element of RGB of the pixel under the cursor (if u take out the cout<<... line it doesn't leak anymore)
#define VERSION 0.5.0
#define _WIN32_WINNT 0x0501 //very important!
#include <windows.h>
#include <iostream>
using namespace std;
POINT pos;
HDC hnd;
struct point {int x; int y;};
int getR(){
POINT pos;
//pos.x=-1;
//pos.y=-1;
GetCursorPos(&pos);
hnd=GetDC(NULL);
COLORREF clr;
clr=GetPixel(hnd,pos.x,pos.y);
delete hnd;
delete &clr;
return (int)GetRValue(clr);
}
int getG(){
POINT pos;
//pos.x=-1;
//pos.y=-1;
GetCursorPos(&pos);
hnd=GetDC(NULL);
COLORREF clr;
clr=GetPixel(hnd,pos.x,pos.y);
delete hnd;
delete &clr;
return (int)GetGValue(clr);
}
byte getB(){
GetCursorPos(&pos);
return GetBValue(GetPixel(GetDC(NULL),pos.x,pos...
}
int main(){
while(true){
Sleep(10);
cout<<(int)getB()<<endl;
}
return 0;
}
Tags: