From 1371eb08d415ec82abc060066dd79297b41e8705 Mon Sep 17 00:00:00 2001 From: Andrey Kiselev Date: Fri, 26 Mar 2004 15:52:47 +0000 Subject: [PATCH] Properly set Photometric Interpretation in case of JPEG compression of grayscale images. --- tools/tiffcp.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tools/tiffcp.c b/tools/tiffcp.c index 537b4910..676b6769 100644 --- a/tools/tiffcp.c +++ b/tools/tiffcp.c @@ -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 @@ -543,12 +543,17 @@ tiffcp(TIFF* in, TIFF* out) && input_compression == COMPRESSION_JPEG ) { TIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); } - if (TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &input_photometric) - && input_photometric == PHOTOMETRIC_RGB) { - if (jpegcolormode == JPEGCOLORMODE_RGB) - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); - else - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); + if (TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &input_photometric)) { + if(input_photometric == PHOTOMETRIC_RGB) { + if (jpegcolormode == JPEGCOLORMODE_RGB) + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, + PHOTOMETRIC_YCBCR); + else + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, + PHOTOMETRIC_RGB); + } else + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, + input_photometric); } } else if (compression == COMPRESSION_SGILOG @@ -1045,8 +1050,7 @@ DECLAREreadFunc(readSeparateStripsIntoBuffer) uint8* bufp = (uint8*) buf; uint32 row; tsample_t s; - - for (row = 0; row < imagelength; row++) { +for (row = 0; row < imagelength; row++) { /* merge channels */ for (s = 0; s < spp; s++) { uint8* bp = bufp + s;