Skip to content

Commit ef4f95c

Browse files
committed
cleanup for Kleis comments
1 parent 0407c36 commit ef4f95c

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

libvips/resample/thumbnail.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,8 @@ vips_thumbnail_build( VipsObject *object )
640640
*/
641641
VipsInterpretation input_interpretation;
642642

643-
/* TRUE if we've premultiplied and need to unpremultiply.
643+
/* The format we need to revert to after unpremultiply.
644644
*/
645-
gboolean have_premultiplied;
646645
VipsBandFormat unpremultiplied_format;
647646

648647
#ifdef DEBUG
@@ -778,19 +777,19 @@ vips_thumbnail_build( VipsObject *object )
778777
vshrink = (double) in->Ysize / target_image_height;
779778
}
780779

780+
/* vips_premultiply() makes a float image, so when we unpremultiply
781+
* below we must cast back to the original format. Use NOTSET to
782+
* meran no pre/unmultiply.
783+
*/
784+
unpremultiplied_format = VIPS_FORMAT_NOTSET;
785+
781786
/* If there's an alpha, we have to premultiply before shrinking. See
782787
* https://github.com/libvips/libvips/issues/291
783788
*/
784-
have_premultiplied = FALSE;
785789
if( vips_image_hasalpha( in ) &&
786790
hshrink != 1.0 &&
787791
vshrink != 1.0 ) {
788-
/* vips_premultiply() makes a float image. When we
789-
* vips_unpremultiply() below, we need to cast back to the
790-
* pre-premultiplied format.
791-
*/
792792
g_info( "premultiplying alpha" );
793-
have_premultiplied = TRUE;
794793
unpremultiplied_format = in->BandFmt;
795794

796795
if( vips_premultiply( in, &t[3], NULL ) )
@@ -804,7 +803,7 @@ vips_thumbnail_build( VipsObject *object )
804803
return( -1 );
805804
in = t[4];
806805

807-
if( have_premultiplied ) {
806+
if( unpremultiplied_format != VIPS_FORMAT_NOTSET ) {
808807
g_info( "unpremultiplying alpha" );
809808
if( vips_unpremultiply( in, &t[5], NULL ) ||
810809
vips_cast( t[5], &t[6], unpremultiplied_format, NULL ) )

0 commit comments

Comments
 (0)