small reformats

plus remove save multiband as separated multiink
This commit is contained in:
John Cupitt 2019-12-07 17:41:53 +00:00
parent 22a1150cb6
commit 40bffa8cc6
2 changed files with 28 additions and 38 deletions

View File

@ -1354,19 +1354,14 @@ rtiff_parse_copy( Rtiff *rtiff, VipsImage *out )
else else
out->Type = VIPS_INTERPRETATION_sRGB; out->Type = VIPS_INTERPRETATION_sRGB;
} }
else if( samples_per_pixel >= 3 &&
if( samples_per_pixel >= 3 &&
photometric_interpretation == PHOTOMETRIC_CIELAB ) photometric_interpretation == PHOTOMETRIC_CIELAB )
out->Type = VIPS_INTERPRETATION_LAB; out->Type = VIPS_INTERPRETATION_LAB;
else if( photometric_interpretation == PHOTOMETRIC_SEPARATED &&
if( samples_per_pixel >= 4 && samples_per_pixel >= 4 &&
photometric_interpretation == PHOTOMETRIC_SEPARATED && inkset == INKSET_CMYK )
inkset == INKSET_CMYK)
out->Type = VIPS_INTERPRETATION_CMYK; out->Type = VIPS_INTERPRETATION_CMYK;
else
if (samples_per_pixel >= 1 &&
photometric_interpretation == PHOTOMETRIC_SEPARATED &&
inkset == INKSET_MULTIINK)
out->Type = VIPS_INTERPRETATION_MULTIBAND; out->Type = VIPS_INTERPRETATION_MULTIBAND;
rtiff->sfn = rtiff_memcpy_line; rtiff->sfn = rtiff_memcpy_line;
@ -2176,17 +2171,17 @@ rtiff_header_read( Rtiff *rtiff, RtiffHeader *header )
uint16 extra_samples_count; uint16 extra_samples_count;
uint16 *extra_samples_types; uint16 *extra_samples_types;
if( !tfget32( rtiff->tiff, TIFFTAG_IMAGEWIDTH, &header->width ) || if( !tfget32( rtiff->tiff, TIFFTAG_IMAGEWIDTH,
!tfget32( rtiff->tiff, TIFFTAG_IMAGELENGTH, &header->height ) || &header->width ) ||
!tfget16( rtiff->tiff, !tfget32( rtiff->tiff, TIFFTAG_IMAGELENGTH,
TIFFTAG_SAMPLESPERPIXEL, &header->samples_per_pixel ) || &header->height ) ||
!tfget16( rtiff->tiff, !tfget16( rtiff->tiff, TIFFTAG_SAMPLESPERPIXEL,
TIFFTAG_BITSPERSAMPLE, &header->bits_per_sample ) || &header->samples_per_pixel ) ||
!tfget16( rtiff->tiff, !tfget16( rtiff->tiff, TIFFTAG_BITSPERSAMPLE,
TIFFTAG_PHOTOMETRIC, &header->bits_per_sample ) ||
!tfget16( rtiff->tiff, TIFFTAG_PHOTOMETRIC,
&header->photometric_interpretation ) || &header->photometric_interpretation ) ||
!tfget16(rtiff->tiff, !tfget16( rtiff->tiff, TIFFTAG_INKSET,
TIFFTAG_INKSET,
&header->inkset ) ) &header->inkset ) )
return( -1 ); return( -1 );

View File

@ -654,9 +654,11 @@ wtiff_write_header( Wtiff *wtiff, Layer *layer )
TIFFSetField( tif, TIFFTAG_BITSPERSAMPLE, TIFFSetField( tif, TIFFTAG_BITSPERSAMPLE,
vips_format_sizeof( wtiff->im->BandFmt ) << 3 ); vips_format_sizeof( wtiff->im->BandFmt ) << 3 );
if (wtiff->im->Type == VIPS_INTERPRETATION_B_W || if( wtiff->im->Type == VIPS_INTERPRETATION_B_W ||
wtiff->im->Type == VIPS_INTERPRETATION_GREY16) { wtiff->im->Type == VIPS_INTERPRETATION_GREY16 ||
// Mono or mono + alpha. wtiff->im->Bands < 3 ) {
/* Mono or mono + alpha.
*/
photometric = wtiff->miniswhite ? photometric = wtiff->miniswhite ?
PHOTOMETRIC_MINISWHITE : PHOTOMETRIC_MINISWHITE :
PHOTOMETRIC_MINISBLACK; PHOTOMETRIC_MINISBLACK;
@ -670,14 +672,7 @@ wtiff_write_header( Wtiff *wtiff, Layer *layer )
else if( wtiff->im->Type == VIPS_INTERPRETATION_CMYK && else if( wtiff->im->Type == VIPS_INTERPRETATION_CMYK &&
wtiff->im->Bands >= 4 ) { wtiff->im->Bands >= 4 ) {
photometric = PHOTOMETRIC_SEPARATED; photometric = PHOTOMETRIC_SEPARATED;
TIFFSetField( tif, TIFFSetField( tif, TIFFTAG_INKSET, INKSET_CMYK );
TIFFTAG_INKSET, INKSET_CMYK );
colour_bands = 4;
}
else if (wtiff->im->Type == VIPS_INTERPRETATION_MULTIBAND ) {
photometric = PHOTOMETRIC_SEPARATED;
TIFFSetField(tif,
TIFFTAG_INKSET, INKSET_MULTIINK);
colour_bands = 4; colour_bands = 4;
} }
else if( wtiff->compression == COMPRESSION_JPEG && else if( wtiff->compression == COMPRESSION_JPEG &&
@ -685,19 +680,19 @@ wtiff_write_header( Wtiff *wtiff, Layer *layer )
wtiff->im->BandFmt == VIPS_FORMAT_UCHAR && wtiff->im->BandFmt == VIPS_FORMAT_UCHAR &&
(!wtiff->rgbjpeg && wtiff->Q < 90) ) { (!wtiff->rgbjpeg && wtiff->Q < 90) ) {
/* This signals to libjpeg that it can do /* This signals to libjpeg that it can do
* YCbCr chrominance subsampling from RGB, not * YCbCr chrominance subsampling from RGB, not
* that we will supply the image as YCbCr. * that we will supply the image as YCbCr.
*/ */
photometric = PHOTOMETRIC_YCBCR; photometric = PHOTOMETRIC_YCBCR;
TIFFSetField( tif, TIFFTAG_JPEGCOLORMODE, TIFFSetField( tif, TIFFTAG_JPEGCOLORMODE,
JPEGCOLORMODE_RGB ); JPEGCOLORMODE_RGB );
colour_bands = 3; colour_bands = 3;
} }
else { else {
/* Some kind of generic multi-band image .. /* Some kind of generic multi-band image with three or
* save the first three bands as RGB, the rest * more bands ... save the first three bands as RGB,
* as alpha. * the rest as alpha.
*/ */
photometric = PHOTOMETRIC_RGB; photometric = PHOTOMETRIC_RGB;
colour_bands = 3; colour_bands = 3;
} }