support CMYKA

This commit is contained in:
John Cupitt 2008-04-17 14:39:54 +00:00
parent 369c3985eb
commit 8bb073cc72
8 changed files with 37 additions and 46 deletions

View File

@ -9,6 +9,7 @@
- fix the en_GB translation
- use meta to preserve resunit between tiff load and save
- small doc improvements
- read and write CMYKA tiff (thanks Doron)
25/1/08 started 7.14.0
- bump all version numbers for new stable

13
TODO
View File

@ -1,16 +1,3 @@
- set res_unit meta in im_tiff2vips, then use that to set res unit default in
im_vips2tiff
- setting :res_inch as a tiff option does not multiply by 2.54 :-( ie.
1 pixel per mm vips image
save as a tiff with res_cm
sets 10 pixels / cm
save as a tiff with res_inch
sets 10 pixels / inch ... wrong!
- test, backport to 7.14
- should check for gettext in configure? see
https://sourceforge.net/tracker/index.php?func=detail&aid=1836080&group_id=100050&atid=626186

View File

@ -356,9 +356,9 @@ AC_SUBST(VIPS_LIBS)
AC_SUBST(PACKAGES_USED)
AC_OUTPUT([
vips-7.14.pc
vipsCC-7.14.pc
vips-7.14.spec
vips-7.15.pc
vipsCC-7.15.pc
vips-7.15.spec
Makefile
include/vips/version.h
include/Makefile

View File

@ -99,6 +99,8 @@
* - remove "b" option on TIFFOpen()
* 9/4/08
* - set IM_META_RESOLUTION_UNIT
* 17/4/08
* - allow CMYKA (thanks Doron)
*/
/*
@ -705,10 +707,10 @@ parse_palette( ReadTiff *rtiff, IMAGE *out )
return( 0 );
}
/* Per-scanline process function for 8-bit RGB/RGBA.
/* Per-scanline process function for 8-bit RGB/RGBA/CMYK/CMYKA.
*/
static void
rgb8_line( PEL *q, PEL *p, int n, IMAGE *im )
rgbcmyk8_line( PEL *q, PEL *p, int n, IMAGE *im )
{
int x, b;
@ -745,7 +747,7 @@ parse_rgb8( ReadTiff *rtiff, IMAGE *out )
out->Coding = IM_CODING_NONE;
out->Type = IM_TYPE_sRGB;
rtiff->sfn = (scanline_process_fn) rgb8_line;
rtiff->sfn = (scanline_process_fn) rgbcmyk8_line;
rtiff->client = out;
return( 0 );
@ -857,42 +859,33 @@ parse_32f( ReadTiff *rtiff, int pm, IMAGE *out )
return( 0 );
}
/* Per-scanline process function for CMYK8.
*/
static void
cmyk8_line( PEL *q, PEL *p, int n, void *dummy )
{
int x;
for( x = 0; x < n; x++ ) {
q[0] = p[0];
q[1] = p[1];
q[2] = p[2];
q[3] = p[3];
q += 4;
p += 4;
}
}
/* Read a CMYK image.
*/
static int
parse_cmyk( ReadTiff *rtiff, IMAGE *out )
{
if( !tfequals( rtiff->tiff, TIFFTAG_SAMPLESPERPIXEL, 4 ) ||
!tfequals( rtiff->tiff, TIFFTAG_BITSPERSAMPLE, 8 ) ||
!tfequals( rtiff->tiff, TIFFTAG_INKSET, INKSET_CMYK ) )
return( -1 );
int bands;
out->Bands = 4;
/* Check other TIFF fields to make sure we can read this. Can have 5
* bands for CMYKA.
*/
if( !tfequals( rtiff->tiff, TIFFTAG_BITSPERSAMPLE, 8 ) ||
!tfequals( rtiff->tiff, TIFFTAG_INKSET, INKSET_CMYK ) ||
!tfget16( rtiff->tiff, TIFFTAG_SAMPLESPERPIXEL, &bands ) )
return( -1 );
if( bands != 4 && bands != 5 ) {
im_error( "im_tiff2vips", _( "4 or 5 bands CMYK TIFF only" ) );
return( -1 );
}
out->Bands = bands;
out->Bbits = 8;
out->BandFmt = IM_BANDFMT_UCHAR;
out->Coding = IM_CODING_NONE;
out->Type = IM_TYPE_CMYK;
rtiff->sfn = cmyk8_line;
rtiff->client = NULL;
rtiff->sfn = (scanline_process_fn) rgbcmyk8_line;
rtiff->client = out;
return( 0 );
}

View File

@ -102,6 +102,8 @@
* - don't try to copy icc profiles when building pyramids (thanks Joe)
* 9/4/08
* - use IM_META_RESOLUTION_UNIT to set default resunit
* 17/4/08
* - allow CMYKA (thanks Doron)
*/
/*
@ -506,6 +508,14 @@ write_tiff_header( TiffWrite *tw, TIFF *tif, int width, int height )
}
break;
case 5:
if( tw->im->Type == IM_TYPE_CMYK ) {
photometric = PHOTOMETRIC_SEPARATED;
TIFFSetField( tif,
TIFFTAG_INKSET, INKSET_CMYK );
}
break;
default:
assert( 0 );
}
@ -1575,8 +1585,8 @@ im_vips2tiff( IMAGE *im, const char *filename )
return( -1 );
}
if( im->Coding == IM_CODING_NONE ) {
if( im->Bands < 1 || im->Bands > 4 ) {
im_error( "im_vips2tiff", _( "1 to 4 bands only" ) );
if( im->Bands < 1 || im->Bands > 5 ) {
im_error( "im_vips2tiff", _( "1 to 5 bands only" ) );
return( -1 );
}
}