Shoutbox

[huh?] ColorRef - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [huh?] ColorRef (/showthread.php?tid=85554)

[huh?] ColorRef by SmokingCookie on 08-23-2008 at 10:26 AM

Hi,

I've seen the term "ColorRef" many times, I've seen the C++ RGB macro, but is there a way to create these values myself?


RE: [huh?] ColorRef by Volv on 08-23-2008 at 01:36 PM

COLORREF (MSDN)

quote:
Originally posted by MSDN
When specifying an explicit RGB color, the COLORREF value has the following hexadecimal form:

0x00bbggrr

The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green; and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF.

RE: [huh?] ColorRef by Matti on 08-23-2008 at 01:48 PM

So if you have a color like #FF8000 (bright yellow), the COLORREF value would be 0x000080FF. :)

Here's an equivalent for the RGB macro you're so familiar with:

code:
function RGB(r, g, b) {
   return ((b & 0xFF) << 16) | ((g & 0xFF) << 8) | (r & 0xFF);
}

RE: [huh?] ColorRef by CookieRevised on 08-23-2008 at 02:08 PM

A COLORREF is just a name for a DWORD value which is a concatenation of the three RGB values of a color. When you view the value in hexadecimal it is very easy to see how it is made:

0x00BBGGRR

Where BB is te blue component (a value from 0 to 255 (decimal))
Where GG is te green component (a value from 0 to 255 (decimal))
Where RR is te red component (a value from 0 to 255 (decimal))

So you can very easly make this value yourself if you know the RGB values. Just binary left shift the individual components:

var Red = 11
var Green = 22
var Blue = 33

with pure arethmetics:
var ColorRef = Blue * 256 * 256 + Green * 256 + Red
or the equivalent:
var ColorRef = (Blue << 16) + (Green << 8) + Red

in VBScript/VB you can also use the RGB() function:
ColorRef = RGB(Red, Green, Blue)

---

A COLORREF value is also used in the Plus! registry settings for some values:
http://www.msgpluslive.net/help/registry/

---

Blah, need to refresh more often again


RE: [huh?] ColorRef by SmokingCookie on 08-23-2008 at 02:34 PM

Thanks lads :)

@ Volv:

I had already seen that page (otherwise, I wouldn't have spammed the forum again :P )