split COLORREF 0x00bbggrr into red green and blue values

Ask for Help on Using the Language With Memory Hacking Software

Moderators: g3nuin3, SpeedWing, WhiteHat, mezzo

split COLORREF 0x00bbggrr into red green and blue values

Postby mezzo » Sun Apr 13, 2008 6:21 am

I need some help with the result obtained with the GetPixel function.
I know the format of the result, but I would like to know how I can easily split the red/green/blue values.
MSDN say to use GetRValue, GetGValue, and GetBValue. But we don't have those yet.
Since the COLORREF is of hex format 0x00bbggrr there should be a simple way to get only the part you want, no ??
Ye, I'm a C noob :-) I admit it.. Any help would be cool. Thanks

Code: Select all
VOID wheredoiclick() {
long clickedX;
long clickedY;
POINT clickedhere;
PrintF("You have 5 seconds to position the mouse before I tell you the X/Y location.");
Sleep(5000);
GetCursorPos(&clickedhere);
PrintF("You clicked X: %u and Y: %u", clickedhere.x, clickedhere.y);
PrintF("move_mouse(%u,%u);", clickedhere.x, clickedhere.y);

// Some colour routines
char * ttwindowname = "some game";
Foreground_window( ttwindowname );
HWND hTST = FindWindow( ttwindowname );
    if ( !hTST ) { return; }

HDC something = GetWindowDC( hTST);
int colors = GetPixel( something, clickedhere.x, clickedhere.y);
PrintF("Colour index of that pices is %u.", colors);
ReleaseDC( hTST, something);

}
- No thanks, I already have a penguin -
User avatar
mezzo
El Mariachi
 
Posts: 739
Joined: Mon Apr 30, 2007 10:27 pm
Location: Antwerp

Postby L. Spiro » Sun Apr 13, 2008 11:58 am

Code: Select all
#define LOBYTE(w)           ((BYTE)((DWORD)(w) & 0xff))
#define HIBYTE(w)           ((BYTE)((DWORD)(w) >> 8))

#define GetRValue(rgb)      (LOBYTE(rgb))
#define GetGValue(rgb)      (LOBYTE(((WORD)(rgb)) >> 8))
#define GetBValue(rgb)      (LOBYTE((rgb)>>16))


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby mezzo » Sun Apr 13, 2008 9:09 pm

cool, I'll go try that right now ! Thanks :-)

( just so I understand, >> shifts the bytes ?)
- No thanks, I already have a penguin -
User avatar
mezzo
El Mariachi
 
Posts: 739
Joined: Mon Apr 30, 2007 10:27 pm
Location: Antwerp

Postby L. Spiro » Sun Apr 13, 2008 9:23 pm

>> = shift bits right (down).
<< = shift bits left (up).


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby mezzo » Mon Apr 14, 2008 4:35 am

cheers, mate !
- No thanks, I already have a penguin -
User avatar
mezzo
El Mariachi
 
Posts: 739
Joined: Mon Apr 30, 2007 10:27 pm
Location: Antwerp


Return to Help

Who is online

Users browsing this forum: No registered users and 0 guests

cron