On Thu, 4 Jan 2024 04:42:24 GMT, Renjith Kannath Pariyangad 
<rkannathp...@openjdk.org> wrote:

>> Hm… If modify the `toRGB` and `fromRGB` methods to use `csRGB` object, then 
>> the test does not fail without the fix.
>> 
>> What's more interesting is that the images are equal before `filter` is 
>> applied.
>
> @aivanov-jdk Thank you for clarifying, I thought he mean to modify `toCIEXYZ` 
> and `fromCIEXYZ`. Yes if we modify `toRGB `and `fromRGB` then it will not 
> pass through fixed area, So we may need to skip this.

The difference between srcColorSpace.fromCIEXYZ and dtsColorSpace.fromCIEXYZ 
can trigger an exception if both have different number of components, for 
example srcColorSpace = CS_GRAY and srcColorSpace.CS_sRGB 
=>ArrayIndexOutOfBoundsException will be triggered.


    private static TestColorSpace createCS(boolean isSrc) {
        ColorSpace cs = ColorSpace.getInstance(
                isSrc ? ColorSpace.CS_GRAY : ColorSpace.CS_sRGB);
        return new TestColorSpace(cs);
    }

    public static void main(String[] args) {
        BufferedImage src = createTestImage(true);
        BufferedImage dest = createTestImage(false);

        ColorSpace mid = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        ColorConvertOp test = new ColorConvertOp(mid, null);
        test.filter(src, dest);
    }

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 1 
out of bounds for length 1
        at 
java.desktop/java.awt.image.ColorConvertOp.nonICCBIFilter(ColorConvertOp.java:821)
        at 
java.desktop/java.awt.image.ColorConvertOp.filter(ColorConvertOp.java:275)
        at NonICCFilterTest.main(NonICCFilterTest.java:97)

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16895#discussion_r1441303144

Reply via email to