summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfwarmerdam <fwarmerdam>2012-06-01 22:22:04 +0000
committerfwarmerdam <fwarmerdam>2012-06-01 22:22:04 +0000
commitf50950efe6fbb2211957fc755d7c9c978f77a629 (patch)
treef1243f95df21b4405ad9d6a690a31fd860b87447
parentf8deeb45a6a0e1ace4c55fc752782b9e21f19aac (diff)
downloadlibtiff-f50950efe6fbb2211957fc755d7c9c978f77a629.tar.gz
Added _SEPARATED CMKY support (#2379)
-rw-r--r--ChangeLog3
-rw-r--r--libtiff/tif_getimage.c124
2 files changed, 79 insertions, 48 deletions
diff --git a/ChangeLog b/ChangeLog
index f36d7574..bced69d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2012-06-01 Frank Warmerdam <warmerdam@google.com>
+ * libtiff/tif_getimage.c: added support for _SEPARATED CMYK images.
+ http://bugzilla.maptools.org/show_bug.cgi?id=2379
+
* libtiff/tif_unix.c: use strerror() to return a more specific error message
on failed open.
http://bugzilla.maptools.org/show_bug.cgi?id=2341
diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c
index 88adf1dc..33de57b1 100644
--- a/libtiff/tif_getimage.c
+++ b/libtiff/tif_getimage.c
@@ -1,4 +1,4 @@
-/* $Id: tif_getimage.c,v 1.80 2012-06-01 00:38:39 fwarmerdam Exp $ */
+/* $Id: tif_getimage.c,v 1.81 2012-06-01 22:22:04 fwarmerdam Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@@ -1527,6 +1527,27 @@ DECLARESepPutFunc(putRGBAAseparate8bittile)
}
/*
+ * 8-bit unpacked CMYK samples => RGBA
+ */
+DECLARESepPutFunc(putCMYKseparate8bittile)
+{
+ (void) img; (void) y;
+ while (h-- > 0) {
+ uint32 rv, gv, bv, kv;
+ uint8* m;
+ for (x = w; x-- > 0;) {
+ kv = 255 - *a++;
+ rv = (kv*(255-*r++))/255;
+ gv = (kv*(255-*g++))/255;
+ bv = (kv*(255-*b++))/255;
+ *cp++ = PACK4(rv,gv,bv,255);
+ }
+ SKEW4(r, g, b, a, fromskew);
+ cp += toskew;
+ }
+}
+
+/*
* 8-bit unpacked samples => RGBA w/ unassociated alpha
*/
DECLARESepPutFunc(putRGBUAseparate8bittile)
@@ -2575,58 +2596,65 @@ PickSeparateCase(TIFFRGBAImage* img)
img->get = TIFFIsTiled(img->tif) ? gtTileSeparate : gtStripSeparate;
img->put.separate = NULL;
switch (img->photometric) {
- case PHOTOMETRIC_MINISWHITE:
- case PHOTOMETRIC_MINISBLACK:
- /* greyscale images processed pretty much as RGB by gtTileSeparate */
- case PHOTOMETRIC_RGB:
- switch (img->bitspersample) {
- case 8:
- if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
- img->put.separate = putRGBAAseparate8bittile;
- else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
- {
- if (BuildMapUaToAa(img))
- img->put.separate = putRGBUAseparate8bittile;
- }
- else
- img->put.separate = putRGBseparate8bittile;
- break;
- case 16:
- if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
- {
- if (BuildMapBitdepth16To8(img))
- img->put.separate = putRGBAAseparate16bittile;
- }
- else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
- {
- if (BuildMapBitdepth16To8(img) &&
- BuildMapUaToAa(img))
- img->put.separate = putRGBUAseparate16bittile;
- }
- else
- {
- if (BuildMapBitdepth16To8(img))
- img->put.separate = putRGBseparate16bittile;
- }
- break;
+ case PHOTOMETRIC_MINISWHITE:
+ case PHOTOMETRIC_MINISBLACK:
+ /* greyscale images processed pretty much as RGB by gtTileSeparate */
+ case PHOTOMETRIC_RGB:
+ switch (img->bitspersample) {
+ case 8:
+ if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
+ img->put.separate = putRGBAAseparate8bittile;
+ else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
+ {
+ if (BuildMapUaToAa(img))
+ img->put.separate = putRGBUAseparate8bittile;
}
+ else
+ img->put.separate = putRGBseparate8bittile;
break;
- case PHOTOMETRIC_YCBCR:
- if ((img->bitspersample==8) && (img->samplesperpixel==3))
+ case 16:
+ if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
{
- if (initYCbCrConversion(img)!=0)
- {
- uint16 hs, vs;
- TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs);
- switch ((hs<<4)|vs) {
- case 0x11:
- img->put.separate = putseparate8bitYCbCr11tile;
- break;
- /* TODO: add other cases here */
- }
- }
+ if (BuildMapBitdepth16To8(img))
+ img->put.separate = putRGBAAseparate16bittile;
+ }
+ else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
+ {
+ if (BuildMapBitdepth16To8(img) &&
+ BuildMapUaToAa(img))
+ img->put.separate = putRGBUAseparate16bittile;
+ }
+ else
+ {
+ if (BuildMapBitdepth16To8(img))
+ img->put.separate = putRGBseparate16bittile;
}
break;
+ }
+ break;
+ case PHOTOMETRIC_SEPARATED:
+ if (img->bitspersample == 8 && img->samplesperpixel == 4)
+ {
+ img->alpha = 1; // Not alpha, but seems like the only way to get 4th band
+ img->put.separate = putCMYKseparate8bittile;
+ }
+ break;
+ case PHOTOMETRIC_YCBCR:
+ if ((img->bitspersample==8) && (img->samplesperpixel==3))
+ {
+ if (initYCbCrConversion(img)!=0)
+ {
+ uint16 hs, vs;
+ TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs);
+ switch ((hs<<4)|vs) {
+ case 0x11:
+ img->put.separate = putseparate8bitYCbCr11tile;
+ break;
+ /* TODO: add other cases here */
+ }
+ }
+ }
+ break;
}
return ((img->get!=NULL) && (img->put.separate!=NULL));
}