try to handle tiffs with 8-bit colormaps
see https://github.com/jcupitt/libvips/issues/220
This commit is contained in:
parent
c805b382fe
commit
f1d901a229
@ -9,6 +9,7 @@
|
||||
- renamed VIPS_FOREIGN_DZ_DEPTH_1 as VIPS_FOREIGN_DZ_DEPTH_ONE etc. to help
|
||||
bindings
|
||||
- vipsthumbnail will return an error code if one or more conversions failed
|
||||
- try to handle tiffs with old-style 8-bit colormaps
|
||||
|
||||
24/12/14 started 7.42.1
|
||||
- add gobject-2.0 to Requires: in vips and vips-cpp .pc files
|
||||
|
@ -152,6 +152,8 @@
|
||||
* - better istiff detector spots bigtiff
|
||||
* 3/12/14
|
||||
* - read any XMP metadata
|
||||
* 19/1/15
|
||||
* - try to handle 8-bit colormaps
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -853,11 +855,32 @@ parse_palette( ReadTiff *rtiff, VipsImage *out )
|
||||
vips_error( "tiff2vips", "%s", _( "bad colormap" ) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
/* Old-style colourmaps were 8-bit. If all the top bytes are zero,
|
||||
* assume we have one of these.
|
||||
*
|
||||
* See: https://github.com/jcupitt/libvips/issues/220
|
||||
*/
|
||||
for( i = 0; i < len; i++ )
|
||||
if( (read->red16[i] >> 8) |
|
||||
(read->green16[i] >> 8) |
|
||||
(read->blue16[i] >> 8) )
|
||||
break;
|
||||
if( i < len )
|
||||
for( i = 0; i < len; i++ ) {
|
||||
read->red8[i] = read->red16[i] >> 8;
|
||||
read->green8[i] = read->green16[i] >> 8;
|
||||
read->blue8[i] = read->blue16[i] >> 8;
|
||||
}
|
||||
else {
|
||||
vips_warn( "tiff2vips", "%s", _( "assuming 8-bit palette" ) );
|
||||
|
||||
for( i = 0; i < len; i++ ) {
|
||||
read->red8[i] = read->red16[i] & 0xff;
|
||||
read->green8[i] = read->green16[i] & 0xff;
|
||||
read->blue8[i] = read->blue16[i] & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
/* Are all the maps equal? We have a mono image.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user