better jpeg-in-tiff YCbCr read
This commit is contained in:
parent
6f865e91e5
commit
6bad533988
@ -32,6 +32,7 @@
|
||||
- now tests for MagickWand before ImageMagick (thanks Adam)
|
||||
- added "-rotate" option to vips2dj
|
||||
- added man page for im_resize_linear
|
||||
- better jpeg-in-tiff YCbCr read (thanks Ole)
|
||||
|
||||
25/1/08 started 7.14.0
|
||||
- bump all version numbers for new stable
|
||||
|
2
TODO
2
TODO
@ -1,5 +1,7 @@
|
||||
- wrap meta() stuff in C++, we need it in py as well
|
||||
|
||||
- TIFF JPEG read needs to map ycbcr->rgb somehow
|
||||
|
||||
- try
|
||||
|
||||
libsrc/convolution$ grep -l offsets *.c
|
||||
|
@ -101,6 +101,8 @@
|
||||
* - set IM_META_RESOLUTION_UNIT
|
||||
* 17/4/08
|
||||
* - allow CMYKA (thanks Doron)
|
||||
* 17/7/08
|
||||
* - convert YCbCr to RGB on read
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -401,45 +403,6 @@ parse_labs( ReadTiff *rtiff, IMAGE *out )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* Per-scanline process function for IM_CODING_LABQ.
|
||||
*/
|
||||
static void
|
||||
ycbcr_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] = 0;
|
||||
|
||||
q += 4;
|
||||
p += 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read a YCbCr image.
|
||||
*/
|
||||
static int
|
||||
parse_ycbcr( ReadTiff *rtiff, IMAGE *out )
|
||||
{
|
||||
if( !tfequals( rtiff->tiff, TIFFTAG_SAMPLESPERPIXEL, 3 ) ||
|
||||
!tfequals( rtiff->tiff, TIFFTAG_BITSPERSAMPLE, 8 ) )
|
||||
return( -1 );
|
||||
|
||||
out->Bands = 4;
|
||||
out->Bbits = 8;
|
||||
out->BandFmt = IM_BANDFMT_UCHAR;
|
||||
out->Coding = IM_CODING_LABQ;
|
||||
out->Type = IM_TYPE_LAB;
|
||||
|
||||
rtiff->sfn = ycbcr_line;
|
||||
rtiff->client = NULL;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* Per-scanline process function for 1 bit images.
|
||||
*/
|
||||
static void
|
||||
@ -707,7 +670,7 @@ parse_palette( ReadTiff *rtiff, IMAGE *out )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* Per-scanline process function for 8-bit RGB/RGBA/CMYK/CMYKA.
|
||||
/* Per-scanline process function for 8-bit RGB/RGBA/CMYK/CMYKA/etc.
|
||||
*/
|
||||
static void
|
||||
rgbcmyk8_line( PEL *q, PEL *p, int n, IMAGE *im )
|
||||
@ -1014,14 +977,6 @@ parse_header( ReadTiff *rtiff, IMAGE *out )
|
||||
|
||||
break;
|
||||
|
||||
case PHOTOMETRIC_YCBCR:
|
||||
/* Easy decision!
|
||||
*/
|
||||
if( parse_ycbcr( rtiff, out ) )
|
||||
return( -1 );
|
||||
|
||||
break;
|
||||
|
||||
case PHOTOMETRIC_MINISWHITE:
|
||||
case PHOTOMETRIC_MINISBLACK:
|
||||
switch( bps ) {
|
||||
@ -1078,8 +1033,18 @@ parse_header( ReadTiff *rtiff, IMAGE *out )
|
||||
|
||||
break;
|
||||
|
||||
case PHOTOMETRIC_YCBCR:
|
||||
/* Sometimes JPEG in TIFF images are tagged as YCBCR. Ask
|
||||
* libtiff to convert to RGB for us.
|
||||
*/
|
||||
TIFFSetField( rtiff->tiff,
|
||||
TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB );
|
||||
if( parse_rgb8( rtiff, out ) )
|
||||
return( -1 );
|
||||
break;
|
||||
|
||||
case PHOTOMETRIC_RGB:
|
||||
/* Plain RGB.
|
||||
/* RGB.
|
||||
*/
|
||||
switch( bps ) {
|
||||
case 8:
|
||||
|
Loading…
Reference in New Issue
Block a user