[poppler] Branch 'poppler-0.14' - poppler/DCTStream.cc poppler/DCTStream.h
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Tue Jul 13 01:31:14 PDT 2010
poppler/DCTStream.cc | 30 ++++++++++++++++++++++++++++++
poppler/DCTStream.h | 1 +
2 files changed, 31 insertions(+)
New commits:
commit dc345471d5e8f14f909a6da3a0708fe4d5db150a
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Tue Jul 13 10:18:01 2010 +0200
Handle ColorTransform in DCT streams when using libjpeg
Fixes bug #28873.
diff --git a/poppler/DCTStream.cc b/poppler/DCTStream.cc
index 5cbaced..2261cb3 100644
--- a/poppler/DCTStream.cc
+++ b/poppler/DCTStream.cc
@@ -58,6 +58,7 @@ static void str_term_source(j_decompress_ptr cinfo)
DCTStream::DCTStream(Stream *strA, int colorXformA) :
FilterStream(strA) {
+ colorXform = colorXformA;
init();
}
@@ -138,6 +139,35 @@ void DCTStream::reset() {
if (!setjmp(src.setjmp_buffer)) {
jpeg_read_header(&cinfo, TRUE);
+
+ // figure out color transform
+ if (colorXform == -1 && !cinfo.saw_Adobe_marker) {
+ if (cinfo.num_components == 3) {
+ if (cinfo.saw_JFIF_marker) {
+ colorXform = 1;
+ } else if (cinfo.cur_comp_info[0]->component_id == 82 &&
+ cinfo.cur_comp_info[1]->component_id == 71 &&
+ cinfo.cur_comp_info[2]->component_id == 66) { // ASCII "RGB"
+ colorXform = 0;
+ } else {
+ colorXform = 1;
+ }
+ } else {
+ colorXform = 0;
+ }
+ } else if (cinfo.saw_Adobe_marker) {
+ colorXform = cinfo.Adobe_transform;
+ }
+
+ switch (cinfo.num_components) {
+ case 3:
+ cinfo.jpeg_color_space = colorXform ? JCS_YCbCr : JCS_RGB;
+ break;
+ case 4:
+ cinfo.jpeg_color_space = colorXform ? JCS_YCCK : JCS_CMYK;
+ break;
+ }
+
jpeg_start_decompress(&cinfo);
row_stride = cinfo.output_width * cinfo.output_components;
diff --git a/poppler/DCTStream.h b/poppler/DCTStream.h
index 6768ff2..81c18e9 100644
--- a/poppler/DCTStream.h
+++ b/poppler/DCTStream.h
@@ -69,6 +69,7 @@ public:
private:
void init();
+ int colorXform;
JSAMPLE *current;
JSAMPLE *limit;
struct jpeg_decompress_struct cinfo;
More information about the poppler
mailing list