This fix resolves problem with handling destination type for the case
when number of color components differs form number of color components
in the jpeg image. Particularly, it happens when we read YCbCr image (3
components) as a grayscale (1 component), and, the opposite case, when
we read grayscaled jpeg as a RGB image.
To resolve this problem we need to:
- adjust java state of the reader after changing output color space
(method JPEGImageReader.checkColorConversion(), lines 900 - 903 and
913 - 916) and set output color space code and number of color
components according to requested output color space.
- use output_component instead of num_components in the native
readImage() for checks and buffer allocations, because this variable
describes format of decoded data, whereas num_components refers to
number of components declared in the jpeg header.
The variable output_components is calculated during the decoder
start, so we have to postpone verification of number of requested
bands and allocation of scanline buffer until the decoder is started.
The rest of changes made initialization of image type specifiers a bit
more lazy: we do not create specifier until the explicit usage. In
combination with postponed initialization of YCC color space, it gives
a chance to avoid CMM initialization and profiles loading if user
decoders only sRGB or grayscaled representation of jpeg image.
Another change in this version is in ICC_Profile.java. Unfortunately,
our deferring strategy cause failures in case of windows online
installation, where PYCC profile is not present.
So we have to check whether this profile is available before creation
of deferred profile instance:
- for case non-jkernel (or completed jkernel) installation we should
check availability of the PYCC profile file and produce deferred
instance only if this file exists.
- for active jkernel case we can create deferred profile for PYCC
because at the moment jkernel alway have the profiles bundle.
Probably, this case should be re-visited if jkernel bundling
strategy will be changed.