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 12/8/14 started 7.40.6
- more doc fixes - more doc fixes
- fix similarity rotate+scale, thanks Topochicho - fix similarity rotate+scale, thanks Topochicho
- fix 16-bit PNG save, thanks John
25/7/14 started 7.40.5 25/7/14 started 7.40.5
- fix a race in im_maxpos_avg() - 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? - 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_object_unref_outputs() needs docs ... bindings will need it
- vips_init() has a deprecation warning, bizarre - vips_init() has a deprecation warning, bizarre

View File

@ -8,6 +8,8 @@
* - auto rshift down to 8 bits during save * - auto rshift down to 8 bits during save
* 19/1/14 * 19/1/14
* - pack and unpack rad to scrgb * - 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; in = out;
} }
} }
else if( in->Bands == 3 && else if( in->Bands >= 3 &&
vips_colourspace_issupported( in ) ) { vips_colourspace_issupported( in ) &&
/* Interpret the Type field for colorimetric images. (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; VipsImage *out;
VipsInterpretation interpretation;
if( vips_colourspace( in, &out, /* Do we make RGB or RGB16? We don't want to squash a 16-bit
VIPS_INTERPRETATION_sRGB, NULL ) ) { * 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 ); g_object_unref( in );
return( -1 ); return( -1 );
} }