This Java tip explains how to relate RGB to gray scale. In the MIDP reference implementation, the mapping from grayscale to the returned color is a simple one: the red, green, and blue components are all set to the grayscale value. That is to say, the following code prints "127" for all three color components:


g.setGrayScale(127);
System.out.println("Red = " + g.getRedComponent( ) + ", green = " + g.
getGreenComponent( ) + ", blue = " + g.getBlueComponent( ));

 

 

 

 Related Tips