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
Please keep your programming questions on the newsgroups.



Sun, 03 Feb 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

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

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

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

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

5. Controlling printed grey scale of color BMPs?

6. VB Colors vs. Web Hex RGB colors

7. Converting RGB-color to HEX color

8. Converting RGB-color to HEX color

9. Finding out RGB value for a system color

10. Color help needed in converting VB's BGR format to RGB output

11. How to convert MSHFlexGrid's color to RGB format

12. Stuffing 'custom colors' in Color Picker

 

 
Powered by phpBB® Forum Software