RFR: JDK-8347377 : Add validation checks for ICC_Profile header fields [v3]
Harshitha Onkar
honkar at openjdk.org
Thu Jan 16 02:19:41 UTC 2025
On Wed, 15 Jan 2025 10:36:58 GMT, Jayathirth D V <jdv at openjdk.org> wrote:
>>> our own profiles do not strictly follow these specification, so if lcms ignores that we can do the same, especially since we fallback to the "Perceptual intent"
>>>
>>> https://github.com/openjdk/jdk/blob/13a1775718f329b02cdeb82f9d3f7d878ac5e771/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSTransform.java#L75
>>
>> Is it for the above reason (it can take ICC Intent as well as Non ICC Intent) that LCMSTransform does NOT validate the value of rendering intent ?
>
>> > The ICC spec. defines only these 4 intents, so I don't see a problem here.
>>
>> our own profiles do not strictly follow these specification, so if lcms ignores that we can do the same, especially since we fallback to the "Perceptual intent"
>>
>> https://github.com/openjdk/jdk/blob/13a1775718f329b02cdeb82f9d3f7d878ac5e771/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSTransform.java#L75
>
> I think only when user sets "Any" rendering intent we fallback to "Perceptual" intent.
> @honkar-jdk What happens when we set some random intent value?
@jayathirthrao
When a random value is added for rendering intent in LCMSTransform as below, LCMS throws CMMException , but when I change to any other **Non-ICC Intents** (as specified in the table 41 above) it passes. Looks like LCMS accepts both ICC and Non-ICC Intents but I not sure if we need to check Non-ICC Intents during profile creation or updation.
The location that @mrserb mentioned in LCMSTransform involves creating a new color space transform using 2 or more profiles.
There is a note about rendering intent in Spec & API doc about being dynamically set and it has value only when profile is used in some context.
_"The rendering intent field shall specify the rendering intent which should be used (or, in the case of a DeviceLink profile, was used) when this profile is (was) combined with another profile. In a sequence of more than two profiles, it applies to the combination of this profile and the next profile in the sequence and not to the entire sequence.
**Typically, the user or application will set the rendering intent dynamically at runtime or embedding time. Therefore, this flag may not have any meaning until the profile is used in some context, e.g. in a DeviceLink or an embedded source profile**."_
Test case:
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
cs.toRGB(new float[3]); //triggers createTransform() -> LCMSTransform
` this.renderingIntent = (renderingIntent == ColorTransform.Any) ? 5 : renderingIntent;`
java.awt.color.CMMException: LCMS error 8: Unsupported intent '5'
at java.desktop/sun.java2d.cmm.lcms.LCMS.createNativeTransform(Native Method)
at java.desktop/sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:113)
at java.desktop/sun.java2d.cmm.lcms.LCMSTransform.doTransform(LCMSTransform.java:114)
at java.desktop/sun.java2d.cmm.lcms.LCMSTransform.colorConvert(LCMSTransform.java:534)
at java.desktop/java.awt.color.ICC_ColorSpace.toRGB(ICC_ColorSpace.java:224)
at ValidateICCHeaderData.main(ValidateICCHeaderData.java:166)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23044#discussion_r1917569546
More information about the client-libs-dev
mailing list