Bug 690207 - read ColorSpace and BitsPerComponent from JPX data
Summary: read ColorSpace and BitsPerComponent from JPX data
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Graphics Library (show other bugs)
Version: master
Hardware: PC Linux
: P4 normal
Assignee: Alex Cherepanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-18 18:08 UTC by Ralph Giles
Modified: 2009-10-17 12:01 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ralph Giles 2008-12-18 18:08:09 UTC
By the spec, the ColorSpace key in JPXDecode image dictionaries is optional, and
if it's not present, the reader is supposed to parse the stream data and choose
an appropriate colorspace.

As of r9297, we just assume it's DeviceRGB. This need to be improved by adding
metadata extraction code to the jpx stream implementation and adding a
postscript operator through which the pdf interpreter can call this code to
obtain the required information. This is slightly complicated by the fact that a
ColorSpace key, if present, is supposed to override what's in the stream. So we
also need to communicate to the actual decoder whether this was the case, or
describe the colour space accurately enough that the effects are the same. This
includes extracting and ICC profile if one is present.

Both JPX implementations already obtain this information, but it's probably more
efficient to implement just the image box parsing in custom code, since it can
read only far enough to get the necessary data and return quickly. See
toolbin/jpxtopdf.c for an example of such an implementation.

As a more minor issue, the BitsPerComponent element is also ignored in favour of
whatever the stream produces. Right now we generally scale everything to 8 bits,
but once this mechanism is in place is can also be used to communicate the best
precision option to the pdf interpreter before the stream is decoded.

Test files are available attached to bugs 688159, 689058 and 689509. However,
they're all rgb, so some examples with other colour spaces must be made.
Comment 1 Ralph Giles 2009-06-17 12:13:36 UTC
Passing this to Alex, who's been working on this.
Comment 2 Alex Cherepanov 2009-10-17 12:01:24 UTC
Finish implementation of ColorSpace extraction from JPX streams. RGB,
Gray, and ICC-based color spaces are extracted and passed to PDF interpreter.
Palette colors need no further processing in PDF interpreter because
they are expanded on C level. Bug 690207.

The following patch has been committed as a rev. 10176.
http://ghostscript.com/pipermail/gs-cvs/2009-October/009901.html

Sample files Bug688159.pdf and Bug689509.pdf now use sRGB color space instead
of DeviceRGB. Raster differences are small, and should be progressions,
because sRGB is the correct color space in this case.