PDA

Click to See Complete Forum and Search --> : RGB Color Conversion


Zero
May 4th, 2001, 08:37 PM
Quick, how do I convert VB's goofy hex color codes to (accruate) RGB? I had it written down someplace but I went and lost it...

~Zero the Inestimable

Sastraxi
May 4th, 2001, 10:14 PM
I believe (was it kedaman ??) had a bunch of usermade functions that he compiled and put on the net... one of them was RGB2HEX.

HarryW
May 4th, 2001, 11:14 PM
The quickest way to do it in VB (I'm talking performance speed, not coding speed) is probably using CopyMemory to copy each byte out, but this is the easy way:


Dim Red As Byte, Green As Byte, Blue As Byte

Blue = RGBValue And 255
Green = (RGBValue \ 256) And 255
Red = (RGBValue \ 65536) And 255

That's from memory so it might not be correct, but I'm pretty sure it is.

Zero
May 5th, 2001, 06:53 AM
Thank you. I'm not too concerned about performance speed for this application. I have a very detailed and accurate image map to test this on (with color deviations of just one bit from object to object) so I'll be able to tell if it's accurate.

~Zero the Inestimable