aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2009-11-04 16:59:54 +0000
committercorvid <corvid@lavabit.com>2009-11-04 16:59:54 +0000
commite1a7010ec491edcf30a790cb54f4448f36dcbf83 (patch)
treef79fe3b11cc5400b412e5bd2b17766baf8298397
parent8f06733c8a70ad1ed61dc2dce59f776c0ab6a9cc (diff)
CMYK JPEGs, at least Adobe ones for now
-rw-r--r--ChangeLog1
-rw-r--r--src/image.hh1
-rw-r--r--src/imgbuf.cc13
-rw-r--r--src/jpeg.c8
4 files changed, 21 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 42adf5d7..b589513e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -46,6 +46,7 @@ dillo-2.2 [??]
- Tooltips
- Fix segfault when radio button lacks name attribute.
- Enable popup menu below bottom of page content (BUG#856).
+ - Handle JPEGs with CMYK color space.
Patches: corvid
+- Support for the letter-spacing property.
Patch: Johannes Hofmann, corvid
diff --git a/src/image.hh b/src/image.hh
index 530e71f2..a66edaae 100644
--- a/src/image.hh
+++ b/src/image.hh
@@ -29,6 +29,7 @@ typedef enum {
DILLO_IMG_TYPE_INDEXED,
DILLO_IMG_TYPE_RGB,
DILLO_IMG_TYPE_GRAY,
+ DILLO_IMG_TYPE_CMYK_INV,
DILLO_IMG_TYPE_NOTSET /* Initial value */
} DilloImgType;
diff --git a/src/imgbuf.cc b/src/imgbuf.cc
index dc95dd71..51f86b74 100644
--- a/src/imgbuf.cc
+++ b/src/imgbuf.cc
@@ -45,6 +45,19 @@ static uchar_t *Imgbuf_rgb_line(const uchar_t *buf,
for (x = 0; x < width; x++)
memset(linebuf + x * 3, buf[x], 3);
break;
+ case DILLO_IMG_TYPE_CMYK_INV:
+ /*
+ * We treat CMYK as if it were "RGBW", and it works. Everyone who is
+ * trying to handle CMYK jpegs is confused by this, and supposedly
+ * the issue is that Adobe CMYK is "wrong" but ubiquitous.
+ */
+ for (x = 0; x < width; x++) {
+ uint_t white = buf[x * 4 + 3];
+ linebuf[x * 3] = buf[x * 4] * white / 0x100;
+ linebuf[x * 3 + 1] = buf[x * 4 + 1] * white / 0x100;
+ linebuf[x * 3 + 2] = buf[x * 4 + 2] * white / 0x100;
+ }
+ break;
case DILLO_IMG_TYPE_RGB:
/* avoid a memcpy here! --Jcid */
return (uchar_t *)buf;
diff --git a/src/jpeg.c b/src/jpeg.c
index ab675b2f..262a1346 100644
--- a/src/jpeg.c
+++ b/src/jpeg.c
@@ -273,8 +273,12 @@ static void Jpeg_write(DilloJpeg *jpeg, void *Buf, uint_t BufSize)
} else if (jpeg->cinfo.num_components == 3) {
type = DILLO_IMG_TYPE_RGB;
} else {
- _MSG("jpeg: can't handle %d component images\n",
- jpeg->cinfo.num_components);
+ MSG("4-component JPEG!\n");
+ if (jpeg->cinfo.jpeg_color_space == JCS_YCCK)
+ MSG("YCCK. Are the colors wrong?\n");
+ if (!jpeg->cinfo.saw_Adobe_marker)
+ MSG("No adobe marker! Is the image shown in reverse video?\n");
+ type = DILLO_IMG_TYPE_CMYK_INV;
}
/*
* If a multiple-scan image is not completely in cache,