From 5ed490cac58d9f548bc141cc334c25dea9bfcaf2 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 9 Oct 2022 20:35:05 -0400 Subject: image: png: Add support for paletted images via auto-expansion. --- chickadee/image/png.scm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/chickadee/image/png.scm b/chickadee/image/png.scm index b6cb3bf..6cdbc14 100644 --- a/chickadee/image/png.scm +++ b/chickadee/image/png.scm @@ -36,7 +36,8 @@ ;;; Enums ;;; -(define PNG_TRANSFORM_IDENTITY 0) +(define PNG_TRANSFORM_IDENTITY #x0000) +(define PNG_TRANSFORM_EXPAND #x0010) (define PNG_COLOR_MASK_PALETTE 1) (define PNG_COLOR_MASK_COLOR 2) @@ -185,7 +186,7 @@ (define (read-png read-struct info-struct) (png-read-png (unwrap-png-read-struct read-struct) (unwrap-png-info-struct info-struct) - PNG_TRANSFORM_IDENTITY + PNG_TRANSFORM_EXPAND %null-pointer)) (define (png-header? header) @@ -247,8 +248,9 @@ (bytevector-u16-ref row offset (endianness big))))) (values gray gray gray 255)))))) + ;; This case should hopefully not happen due to using the + ;; PNG_TRANSFORM_EXPAND read flag, but just in case... ((= color-type PNG_COLOR_TYPE_PALETTE) - ;; TODO: Handle palettes. (raise-exception (make-exception-with-message "PNG images using color palettes are not supported"))) -- cgit v1.2.3