fix 16-bit PNG save

see

https://github.com/jcupitt/libvips/issues/156
This commit is contained in:
John Cupitt 2014-08-18 13:54:06 +01:00
parent 0b896119d4
commit cb2b217434
3 changed files with 21 additions and 9 deletions

View File

@ -1,6 +1,7 @@
12/8/14 started 7.40.6
- more doc fixes
- fix similarity rotate+scale, thanks Topochicho
- fix 16-bit PNG save, thanks John
25/7/14 started 7.40.5
- fix a race in im_maxpos_avg()

4
TODO
View File

@ -1,9 +1,5 @@
- can we pick the vipsthumbnail int shrink factor more intelligently?
- did we include the exif patch in the latest windows build? check on laptop
we don't seem to have this fix in the repository!
- vips_object_unref_outputs() needs docs ... bindings will need it
- vips_init() has a deprecation warning, bizarre

View File

@ -8,6 +8,8 @@
* - auto rshift down to 8 bits during save
* 19/1/14
* - pack and unpack rad to scrgb
* 18/8/14
* - fix conversion to 16-bit RGB, thanks John
*/
/*
@ -1228,14 +1230,27 @@ vips_foreign_convert_saveable( VipsForeignSave *save )
in = out;
}
}
else if( in->Bands == 3 &&
vips_colourspace_issupported( in ) ) {
/* Interpret the Type field for colorimetric images.
else if( in->Bands >= 3 &&
vips_colourspace_issupported( in ) &&
(class->saveable == VIPS_SAVEABLE_RGB ||
class->saveable == VIPS_SAVEABLE_RGBA ||
class->saveable == VIPS_SAVEABLE_RGB_CMYK) ) {
/* Use vips_colourspace() to make an RGB image from LAB or
* whatever this thing is.
*/
VipsImage *out;
VipsInterpretation interpretation;
if( vips_colourspace( in, &out,
VIPS_INTERPRETATION_sRGB, NULL ) ) {
/* Do we make RGB or RGB16? We don't want to squash a 16-bit
* RGB down to 8 bits if the saver supports 16.
*/
if( vips_band_format_is8bit(
class->format_table[in->BandFmt] ) )
interpretation = VIPS_INTERPRETATION_sRGB;
else
interpretation = VIPS_INTERPRETATION_RGB16;
if( vips_colourspace( in, &out, interpretation, NULL ) ) {
g_object_unref( in );
return( -1 );
}