Revert "fix tiff writer for labQ with more bands"

This reverts commit bb3955193daa98b35e4fc69f8ad39cbb3d0d2fa8.
This commit is contained in:
Angel Sánchez 2019-07-22 09:54:24 +02:00 committed by John Cupitt
parent cce739bed9
commit 64f1b60b14
1 changed files with 7 additions and 11 deletions

View File

@ -628,7 +628,7 @@ wtiff_write_header( Wtiff *wtiff, Layer *layer )
/* And colour fields. /* And colour fields.
*/ */
if( wtiff->im->Coding == VIPS_CODING_LABQ ) { 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_BITSPERSAMPLE, 8 );
TIFFSetField( tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CIELAB ); 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. /* Sizeof a line of bytes in the TIFF tile.
*/ */
if( im->Coding == VIPS_CODING_LABQ ) if( im->Coding == VIPS_CODING_LABQ )
wtiff->tls = wtiff->tilew * (im->Bands - 1); wtiff->tls = wtiff->tilew * 3;
else if( wtiff->onebit ) else if( wtiff->onebit )
wtiff->tls = VIPS_ROUND_UP( wtiff->tilew, 8 ) / 8; wtiff->tls = VIPS_ROUND_UP( wtiff->tilew, 8 ) / 8;
else else
@ -1115,10 +1115,9 @@ wtiff_new( VipsImage *im, const char *filename,
/* Convert VIPS LabQ to TIFF LAB. Just take the first three bands. /* Convert VIPS LabQ to TIFF LAB. Just take the first three bands.
*/ */
static void static void
LabQ2LabC( VipsPel *q, VipsPel *p, int n, int bands ) LabQ2LabC( VipsPel *q, VipsPel *p, int n )
{ {
int x; int x;
int b;
for( x = 0; x < n; x++ ) { for( x = 0; x < n; x++ ) {
/* Get most significant 8 bits of lab. /* 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[1] = p[1];
q[2] = p[2]; q[2] = p[2];
for (b = 4; b < bands; ++b) p += 4;
q[b-1] = p[b]; q += 3;
p += bands;
q += bands - 1;
} }
} }
@ -1282,7 +1278,7 @@ wtiff_pack2tiff( Wtiff *wtiff, Layer *layer,
VipsPel *p = (VipsPel *) VIPS_REGION_ADDR( in, area->left, y ); VipsPel *p = (VipsPel *) VIPS_REGION_ADDR( in, area->left, y );
if( wtiff->im->Coding == VIPS_CODING_LABQ ) if( wtiff->im->Coding == VIPS_CODING_LABQ )
LabQ2LabC( q, p, area->width, wtiff->im->Bands ); LabQ2LabC( q, p, area->width );
else if( wtiff->onebit ) else if( wtiff->onebit )
eightbit2onebit( wtiff, q, p, area->width ); eightbit2onebit( wtiff, q, p, area->width );
else if( (in->im->Bands == 1 || in->im->Bands == 2) && 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. /* Any repacking necessary.
*/ */
if( im->Coding == VIPS_CODING_LABQ ) { if( im->Coding == VIPS_CODING_LABQ ) {
LabQ2LabC( wtiff->tbuf, p, im->Xsize, wtiff->im->Bands ); LabQ2LabC( wtiff->tbuf, p, im->Xsize );
p = wtiff->tbuf; p = wtiff->tbuf;
} }
else if( im->BandFmt == VIPS_FORMAT_SHORT && else if( im->BandFmt == VIPS_FORMAT_SHORT &&