How to find a rgb color's equivalance in a grey color scale ?
Author Message
How to find a rgb color's equivalance in a grey color scale ?

How to find  a rgb color's equivalance in a grey color scale ?

I need to translate RGB colors into grey scale color.
Have you any ideas ?
Best regards.
Pascal.

Sun, 03 Feb 2002 03:00:00 GMT
How to find a rgb color's equivalance in a grey color scale ?
Pascal...

Quote:
> How to find  a rgb color's equivalance in a grey color scale ?

Try the following. I didn't write this code, and I'm not entirely sure who
did; I pulled it off a newsgroup at one time because it looked useful.

Function GreyScale (ByVal Colr As Long) As Integer
'Takes a long integer color value and converts it
'to an equivalent grayscale value between 0 and 255
Dim R As Long, G As Long, B As Long

'Break up long color value into red, green, blue
R = Colr Mod 256
Colr = Colr \ 256
G = Colr Mod 256
Colr = Colr \ 256
B = Colr Mod 256

'Find equivalent grayscale value, 0 - 255.
GreyScale = 76 * R / 255 + 150 * G / 255 + 28 * B / 255

End Function

--
Ben Baird, MVP
Visual Basic Thunder
http://www.vbthunder.com

Sun, 03 Feb 2002 03:00:00 GMT

 Page 1 of 1 [ 2 post ]

Relevant Pages