webpsave_buffer no longer ignores @lossless

the @lossless arg to webpsave buffer was never wired up to anything,
thanks aaron42net.

see

https://github.com/jcupitt/libvips/issues/410
This commit is contained in:
John Cupitt 2016-03-31 21:48:40 +01:00
parent 65be59e3dc
commit f3835ef0bf
2 changed files with 38 additions and 12 deletions

View File

@ -21,6 +21,7 @@
- switches to disable PPM, Rad and Analyze support - switches to disable PPM, Rad and Analyze support
- added VIPS_COUNT_PIXELS(), overcomputation tracking - added VIPS_COUNT_PIXELS(), overcomputation tracking
- @out_format in vips_system() can contain [options] - @out_format in vips_system() can contain [options]
- webpsave_buffer no longer ignores @lossless, thanks aaron42net
24/3/16 started 8.2.4 24/3/16 started 8.2.4
- fix nohalo and vsqbs interpolators, thanks Rafael - fix nohalo and vsqbs interpolators, thanks Rafael

View File

@ -2,6 +2,8 @@
* *
* 6/8/13 * 6/8/13
* - from vips2jpeg.c * - from vips2jpeg.c
* 31/5/16
* - buffer write ignored lossless, thanks aaron42net
*/ */
/* /*
@ -131,24 +133,47 @@ vips__webp_write_buffer( VipsImage *in, void **obuf, size_t *olen,
int Q, gboolean lossless ) int Q, gboolean lossless )
{ {
VipsImage *memory; VipsImage *memory;
webp_encoder encoder;
if( !(memory = vips_image_copy_memory( in )) ) if( !(memory = vips_image_copy_memory( in )) )
return( -1 ); return( -1 );
if( in->Bands == 4 ) if( lossless ) {
encoder = WebPEncodeRGBA; webp_encoder_lossless encoder;
else
encoder = WebPEncodeRGB;
if( !(*olen = encoder( VIPS_IMAGE_ADDR( memory, 0, 0 ), if( in->Bands == 4 )
memory->Xsize, memory->Ysize, encoder = WebPEncodeLosslessRGBA;
VIPS_IMAGE_SIZEOF_LINE( memory ), else
Q, (uint8_t **) obuf )) ) { encoder = WebPEncodeLosslessRGB;
VIPS_UNREF( memory );
vips_error( "vips2webp", "%s", _( "unable to encode" ) ); if( !(*olen = encoder( VIPS_IMAGE_ADDR( memory, 0, 0 ),
return( -1 ); memory->Xsize, memory->Ysize,
VIPS_IMAGE_SIZEOF_LINE( memory ),
(uint8_t **) obuf )) ) {
VIPS_UNREF( memory );
vips_error( "vips2webp",
"%s", _( "unable to encode" ) );
return( -1 );
}
} }
else {
webp_encoder encoder;
if( in->Bands == 4 )
encoder = WebPEncodeRGBA;
else
encoder = WebPEncodeRGB;
if( !(*olen = encoder( VIPS_IMAGE_ADDR( memory, 0, 0 ),
memory->Xsize, memory->Ysize,
VIPS_IMAGE_SIZEOF_LINE( memory ),
Q, (uint8_t **) obuf )) ) {
VIPS_UNREF( memory );
vips_error( "vips2webp",
"%s", _( "unable to encode" ) );
return( -1 );
}
}
VIPS_UNREF( memory ); VIPS_UNREF( memory );
return( 0 ); return( 0 );