changeset 12:9b00d4206f99

Implement support for one type of grayscale TIFF.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 08 Dec 2016 22:41:01 +0200
parents e70eb0e6acd5
children df9f2fee4285
files bpgenc.c
diffstat 1 files changed, 36 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/bpgenc.c	Thu Dec 08 21:40:44 2016 +0200
+++ b/bpgenc.c	Thu Dec 08 22:41:01 2016 +0200
@@ -984,6 +984,13 @@
     // Check basics
     switch (img_pmetric)
     {
+        case PHOTOMETRIC_MINISBLACK:
+            img_format = BPG_FORMAT_GRAY;
+            color_space = BPG_CS_YCbCr;
+            if (img_spp != 1)
+                err_spp = 1;
+            break;
+
         case PHOTOMETRIC_RGB:
             img_format = BPG_FORMAT_444;
             if (img_spp < 3)
@@ -1108,6 +1115,35 @@
                     }
                 }
                 break;
+
+            case PHOTOMETRIC_MINISBLACK:
+                if (img_depth == 16)
+                {
+                    luma16_to_gray(&cvt,
+                        (PIXEL *)(img->data[0] + y * img->linesize[0]),
+                        (uint16_t *) buf, img->w, img_spp);
+
+                    if (img_alpha)
+                    {
+                        gray16_to_gray(&cvt,
+                            (PIXEL *)(img->data[1] + y * img->linesize[1]),
+                            ((uint16_t *) buf) + 1, img->w, 2);
+                    }
+                }
+                else
+                {
+                    luma8_to_gray(&cvt,
+                        (PIXEL *)(img->data[0] + y * img->linesize[0]),
+                        (uint8_t *) buf, img->w, img_spp);
+
+                    if (img_alpha)
+                    {
+                        gray8_to_gray(&cvt,
+                            (PIXEL *)(img->data[1] + y * img->linesize[1]),
+                            ((uint8_t *) buf) + 1, img->w, 2);
+                    }
+                }
+                break;
         }
     }