Thanks!

I wasn't sure about using Color.WHITE with grayscale images (noob paranoïa I guess :-) ).

D.

2005/7/20, Jerry Evans <[EMAIL PROTECTED]>:
> The first two tests pass smoothly but for the last one I get a failure
> on the "white color" test:
> junit.framework.AssertionFailedError: expected:<255> but was:<252>
>
> Why are the luminance values only covering the [0..252] range ?


It looks like you're hitting a precision issue in the particular Color
constructor you're
using.  If you use the static Color.WHITE from the Color class, you
should be
able to avoid this problem, as the following code shows:

% more Test.java
import java.awt.Color;
import java.awt.color.ColorSpace;


public class Test {

    public static void main(String argv[]) {
        ColorSpace gcs = ColorSpace.getInstance (ColorSpace.CS_GRAY);
        Color white = new Color(gcs, new float[] {gcs.getMaxValue(0)}, 1f);
        System.out.println("sRGB components for constructed white:");
        System.out.println("Red: " + white.getRed());
        System.out.println("Green: " + white.getGreen());
        System.out.println("Blue: " + white.getBlue());
        System.out.println("Alpha: " + white.getAlpha ());
        System.out.println("");
        System.out.println("sRGB components for Color.WHITE:");
        System.out.println("Red: " + Color.WHITE.getRed());
        System.out.println ("Green: " + Color.WHITE.getGreen());
        System.out.println("Blue: " + Color.WHITE.getBlue());
        System.out.println("Alpha: " + Color.WHITE.getAlpha());
    }
}
%java Test
sRGB components for constructed white:
Red: 252
Green: 254
Blue: 254
Alpha: 255

sRGB components for Color.WHITE:
Red: 255
Green: 255
Blue: 255
Alpha: 255
%


Jerry





=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to