# HG changeset patch # User Matti Hamalainen # Date 1481102619 -7200 # Node ID 690bf78c1ce93c94fb623820b495038bd526ddd4 # Parent 524eae707ba45827fb7629a7999381991bf183b0 Initial implementation of alpha channel support for TIFF images. diff -r 524eae707ba4 -r 690bf78c1ce9 bpgenc.c --- a/bpgenc.c Wed Dec 07 10:38:38 2016 +0200 +++ b/bpgenc.c Wed Dec 07 11:23:39 2016 +0200 @@ -950,7 +950,7 @@ uint16_t img_esmp, *img_esmp_types; TIFFGetField(tif, TIFFTAG_EXTRASAMPLES, &img_esmp, &img_esmp_types); - img_alpha = img_esmp == 1 && img_esmp_types[0] == EXTRASAMPLE_UNASSALPHA; + img_alpha = img_esmp == 1 && img_esmp_types[0] == EXTRASAMPLE_ASSOCALPHA; } else img_alpha = 0; @@ -985,6 +985,22 @@ (PIXEL *)(img->data[1] + y * img->linesize[1]), (PIXEL *)(img->data[2] + y * img->linesize[2]), buf, img->w, img_spp); + + if (img_alpha) + { + if (idx) + { + gray16_to_gray(&cvt, + (PIXEL *)(img->data[3] + y * img->linesize[3]), + ((uint16_t *) buf) + 3, img->w, 4); + } + else + { + gray8_to_gray(&cvt, + (PIXEL *)(img->data[3] + y * img->linesize[3]), + ((uint8_t *) buf) + 3, img->w, 4); + } + } }