Skip to main content
GameDev.net gamedev.net
🔒 Locked

RGB from COLORREF

Started by DefCom Oct 17, 2003 at 7:11 AM 4 replies 6.4k views
Original Post
DefCom
DefCom
Hi, just a quicky. Could someone please tell me how to get the rgb value from a COLORREF, i have searched the MSDN and the forums. I am sure it is something simple, but beyond me. Thanks.
DefCom
DefCom
Would you beleive it, 2 seconds after pressing post i got it.



col = GetPixel(dc2, c,r); //col, row

unsigned long red = (col >> 0);
unsigned long green = (col >> 8);
unsigned long blue = col>>16;



[edited by - Defcom on October 17, 2003 8:13:25 AM]
Drazgal
Drazgal
You didnt search very har din MSDN! If you have searched for COLORREF in the index then used the color macro link at the bottom of that page you would''ve found:

GetBValue
GetRValue
GetGValue

Then again they do exactly what the code you have does anyway
Endurion
Endurion
Nah, he forgot to mask off the other parts:

col = GetPixel(dc2, c,r); //col, row

unsigned long red = ( (col >> 0) & 0xff );
unsigned long green = ( (col >> 8) & 0xff );
unsigned long blue = col>>16; // automaskoff
Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>
DefCom
DefCom
Thanks for those constructive responces.

I didn''t forget to mask, when i masked i only got dark shades of green.

Why unsigned longs, because the sample i ripped off, used them and why change what works.

The COLORREF had no getRValue... mentioned in the MSDN i have on CD, allthough i did find by typing getRValue...

Why am i doing this? I am doing a computer vision project that is going quite nicely, now that i can mess with RGB values from my webcam.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.