From 64f1b60b14daacc9323b05f4578c5c707ef9dc14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Angel=20S=C3=A1nchez?= Date: Mon, 22 Jul 2019 09:54:24 +0200 Subject: [PATCH] Revert "fix tiff writer for labQ with more bands" This reverts commit bb3955193daa98b35e4fc69f8ad39cbb3d0d2fa8. --- libvips/foreign/vips2tiff.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c index cc560d7e..fca3d64e 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -628,7 +628,7 @@ wtiff_write_header( Wtiff *wtiff, Layer *layer ) /* And colour fields. */ if( wtiff->im->Coding == VIPS_CODING_LABQ ) { - TIFFSetField( tif, TIFFTAG_SAMPLESPERPIXEL, wtiff->im->Bands - 1 ); + TIFFSetField( tif, TIFFTAG_SAMPLESPERPIXEL, 3 ); TIFFSetField( tif, TIFFTAG_BITSPERSAMPLE, 8 ); TIFFSetField( tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CIELAB ); } @@ -1067,7 +1067,7 @@ wtiff_new( VipsImage *im, const char *filename, /* Sizeof a line of bytes in the TIFF tile. */ if( im->Coding == VIPS_CODING_LABQ ) - wtiff->tls = wtiff->tilew * (im->Bands - 1); + wtiff->tls = wtiff->tilew * 3; else if( wtiff->onebit ) wtiff->tls = VIPS_ROUND_UP( wtiff->tilew, 8 ) / 8; else @@ -1115,10 +1115,9 @@ wtiff_new( VipsImage *im, const char *filename, /* Convert VIPS LabQ to TIFF LAB. Just take the first three bands. */ static void -LabQ2LabC( VipsPel *q, VipsPel *p, int n, int bands ) +LabQ2LabC( VipsPel *q, VipsPel *p, int n ) { int x; - int b; for( x = 0; x < n; x++ ) { /* Get most significant 8 bits of lab. @@ -1127,11 +1126,8 @@ LabQ2LabC( VipsPel *q, VipsPel *p, int n, int bands ) q[1] = p[1]; q[2] = p[2]; - for (b = 4; b < bands; ++b) - q[b-1] = p[b]; - - p += bands; - q += bands - 1; + p += 4; + q += 3; } } @@ -1282,7 +1278,7 @@ wtiff_pack2tiff( Wtiff *wtiff, Layer *layer, VipsPel *p = (VipsPel *) VIPS_REGION_ADDR( in, area->left, y ); if( wtiff->im->Coding == VIPS_CODING_LABQ ) - LabQ2LabC( q, p, area->width, wtiff->im->Bands ); + LabQ2LabC( q, p, area->width ); else if( wtiff->onebit ) eightbit2onebit( wtiff, q, p, area->width ); else if( (in->im->Bands == 1 || in->im->Bands == 2) && @@ -1368,7 +1364,7 @@ wtiff_layer_write_strip( Wtiff *wtiff, Layer *layer, VipsRegion *strip ) /* Any repacking necessary. */ if( im->Coding == VIPS_CODING_LABQ ) { - LabQ2LabC( wtiff->tbuf, p, im->Xsize, wtiff->im->Bands ); + LabQ2LabC( wtiff->tbuf, p, im->Xsize ); p = wtiff->tbuf; } else if( im->BandFmt == VIPS_FORMAT_SHORT &&