enable alpha in heifsave

Check for image alpha and enable it. There seem to be some
non-transparent tiles, curiously.

See https://github.com/libvips/libvips/issues/1411
This commit is contained in:
John Cupitt 2019-09-01 16:58:50 +01:00
parent 75b45cc2ef
commit da8cee048f
2 changed files with 10 additions and 7 deletions

View File

@ -11,7 +11,7 @@
- add vips_switch() / vips_case() ... fast many-way ifthenelse
- better const handling for arithmetic operators fixes comparisons against out
of range values
- handle alpha in heifload [meyermarcel]
- handle alpha in heifload / heifsave [meyermarcel]
31/8/19 started 8.8.3
- revert sharpen restoring the input colourspace

View File

@ -4,6 +4,8 @@
* - from niftisave.c
* 3/7/19 [lovell]
* - add "compression" option
* 1/9/19 [meyermarcel]
* - save alpha when necessary
*/
/*
@ -199,9 +201,7 @@ vips_foreign_save_heif_write_page( VipsForeignSaveHeif *heif, int page )
#ifdef HAVE_HEIF_ENCODING_OPTIONS_ALLOC
options = heif_encoding_options_alloc();
/* FIXME .. should be an option, though I don't know of any way to
* test it
*/
if( vips_image_hasalpha( save->ready ) )
options->save_alpha_channel = 1;
#else /*!HAVE_HEIF_ENCODING_OPTIONS_ALLOC*/
options = NULL;
@ -294,6 +294,7 @@ vips_foreign_save_heif_build( VipsObject *object )
VipsForeignSaveHeif *heif = (VipsForeignSaveHeif *) object;
struct heif_error error;
enum heif_chroma chroma;
if( VIPS_OBJECT_CLASS( vips_foreign_save_heif_parent_class )->
build( object ) )
@ -335,8 +336,10 @@ vips_foreign_save_heif_build( VipsObject *object )
/* Make a heif image the size of a page. We send sink_disc() output
* here and write a frame each time it fills.
*/
chroma = vips_image_hasalpha( save->ready ) ?
heif_chroma_interleaved_RGBA : heif_chroma_interleaved_RGB;
error = heif_image_create( heif->page_width, heif->page_height,
heif_colorspace_RGB, heif_chroma_interleaved_RGB, &heif->img );
heif_colorspace_RGB, chroma, &heif->img );
if( error.code ) {
vips__heif_error( &error );
return( -1 );
@ -394,7 +397,7 @@ vips_foreign_save_heif_class_init( VipsForeignSaveHeifClass *class )
foreign_class->suffs = vips__heif_suffs;
save_class->saveable = VIPS_SAVEABLE_RGB;
save_class->saveable = VIPS_SAVEABLE_RGBA_ONLY;
save_class->format_table = vips_heif_bandfmt;
VIPS_ARG_INT( class, "Q", 10,