Properly set Photometric Interpretation in case of JPEG compression of

grayscale images.
This commit is contained in:
Andrey Kiselev 2004-03-26 15:52:47 +00:00
parent 82766ccd31
commit 1371eb08d4

View File

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/tools/tiffcp.c,v 1.20 2004-03-26 11:39:31 dron Exp $ */ /* $Id: tiffcp.c,v 1.21 2004-03-26 15:52:47 dron Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -543,12 +543,17 @@ tiffcp(TIFF* in, TIFF* out)
&& input_compression == COMPRESSION_JPEG ) { && input_compression == COMPRESSION_JPEG ) {
TIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); TIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
} }
if (TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &input_photometric) if (TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &input_photometric)) {
&& input_photometric == PHOTOMETRIC_RGB) { if(input_photometric == PHOTOMETRIC_RGB) {
if (jpegcolormode == JPEGCOLORMODE_RGB) if (jpegcolormode == JPEGCOLORMODE_RGB)
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); TIFFSetField(out, TIFFTAG_PHOTOMETRIC,
else PHOTOMETRIC_YCBCR);
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); else
TIFFSetField(out, TIFFTAG_PHOTOMETRIC,
PHOTOMETRIC_RGB);
} else
TIFFSetField(out, TIFFTAG_PHOTOMETRIC,
input_photometric);
} }
} }
else if (compression == COMPRESSION_SGILOG else if (compression == COMPRESSION_SGILOG
@ -1045,8 +1050,7 @@ DECLAREreadFunc(readSeparateStripsIntoBuffer)
uint8* bufp = (uint8*) buf; uint8* bufp = (uint8*) buf;
uint32 row; uint32 row;
tsample_t s; tsample_t s;
for (row = 0; row < imagelength; row++) {
for (row = 0; row < imagelength; row++) {
/* merge channels */ /* merge channels */
for (s = 0; s < spp; s++) { for (s = 0; s < spp; s++) {
uint8* bp = bufp + s; uint8* bp = bufp + s;