changeset 6:690bf78c1ce9

Initial implementation of alpha channel support for TIFF images.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 07 Dec 2016 11:23:39 +0200
parents 524eae707ba4
children 6dc09314d44b
files bpgenc.c
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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);
+            }
+        }
     }