Skip to content

Commit bf597b8

Browse files
Revert "Correctly decode Adobe CMYK JPEGs in PDF export"
From further testing and investigation it appears that many PDF viewers already have a workaround to invert Adobe CMYK JPEGs, so our generated PDFs display incorrectly with those viewers due to double-inversion. Further investigation will be needed to find a better solution that doesn't cause regression for some PDF viewers; perhaps PDF viewers that lack this inversion workaround should be changed to include it. For now we'll drop the patch to avoid shipping the regression in 1.16.0. This reverts commit b207a93. Reference: https://bugs.freedesktop.org/show_bug.cgi?id=97612 Fixes: https://gitlab.freedesktop.org/cairo/cairo/issues/156
1 parent 868998a commit bf597b8

File tree

3 files changed

+0
-24
lines changed

3 files changed

+0
-24
lines changed

src/cairo-image-info-private.h

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ typedef struct _cairo_image_info {
4343
int height;
4444
int num_components;
4545
int bits_per_component;
46-
int is_adobe_jpeg;
4746
} cairo_image_info_t;
4847

4948
cairo_private cairo_int_status_t

src/cairo-image-info.c

-21
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@
6767
#define SOF14 0xce
6868
#define SOF15 0xcf
6969

70-
/* Start of tag markers */
71-
#define APP14 0xee /* Adobe */
72-
7370
static const unsigned char *
7471
_jpeg_skip_segment (const unsigned char *p)
7572
{
@@ -97,8 +94,6 @@ _cairo_image_info_get_jpeg_info (cairo_image_info_t *info,
9794
{
9895
const unsigned char *p = data;
9996

100-
info->is_adobe_jpeg = FALSE;
101-
10297
while (p + 1 < data + length) {
10398
if (*p != 0xff)
10499
return CAIRO_INT_STATUS_UNSUPPORTED;
@@ -136,18 +131,6 @@ _cairo_image_info_get_jpeg_info (cairo_image_info_t *info,
136131
_jpeg_extract_info (info, p);
137132
return CAIRO_STATUS_SUCCESS;
138133

139-
case APP14:
140-
/* "Adobe" tags segment indicates inverted CMYK (in
141-
* CMYK images). */
142-
if (p + 12 > data + length)
143-
return CAIRO_INT_STATUS_UNSUPPORTED;
144-
145-
info->is_adobe_jpeg =
146-
(0 == strncmp((const char *)(p + 3), "Adobe", 5));
147-
148-
p = _jpeg_skip_segment(p);
149-
break;
150-
151134
default:
152135
if (*p >= RST_begin && *p <= RST_end) {
153136
p++;
@@ -223,7 +206,6 @@ _jpx_extract_info (const unsigned char *p, cairo_image_info_t *info)
223206
info->width = get_unaligned_be32 (p + 4);
224207
info->num_components = (p[8] << 8) + p[9];
225208
info->bits_per_component = p[10];
226-
info->is_adobe_jpeg = FALSE;
227209
}
228210

229211
cairo_int_status_t
@@ -301,8 +283,6 @@ _cairo_image_info_get_png_info (cairo_image_info_t *info,
301283
p += 4;
302284
info->height = get_unaligned_be32 (p);
303285

304-
info->is_adobe_jpeg = FALSE;
305-
306286
return CAIRO_STATUS_SUCCESS;
307287
}
308288

@@ -415,7 +395,6 @@ _jbig2_extract_info (cairo_image_info_t *info, const unsigned char *p)
415395
info->height = get_unaligned_be32 (p + 4);
416396
info->num_components = 1;
417397
info->bits_per_component = 1;
418-
info->is_adobe_jpeg = FALSE;
419398
}
420399

421400
cairo_int_status_t

src/cairo-pdf-surface.c

-2
Original file line numberDiff line numberDiff line change
@@ -3169,15 +3169,13 @@ _cairo_pdf_surface_emit_jpeg_image (cairo_pdf_surface_t *surface,
31693169
" /Height %d\n"
31703170
" /ColorSpace %s\n"
31713171
" /Interpolate %s\n"
3172-
"%s"
31733172
" /BitsPerComponent %d\n"
31743173
"%s"
31753174
" /Filter /DCTDecode\n",
31763175
info.width,
31773176
info.height,
31783177
colorspace,
31793178
surface_entry->interpolate ? "true" : "false",
3180-
info.is_adobe_jpeg && info.num_components == 4 ? " /Decode [ 1 0 1 0 1 0 1 0 ]\n" : "",
31813179
info.bits_per_component,
31823180
smask_buf);
31833181
}

0 commit comments

Comments
 (0)