summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2022-10-09 20:35:05 -0400
committerDavid Thompson <dthompson2@worcester.edu>2022-10-09 20:35:05 -0400
commit5ed490cac58d9f548bc141cc334c25dea9bfcaf2 (patch)
treef4419ab428b5d592b2cefc10fb24d39cfd635679
parent9b03d0709c9f5d2d2e9891f1c3cce3638ff76a27 (diff)
image: png: Add support for paletted images via auto-expansion.
-rw-r--r--chickadee/image/png.scm8
1 files 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")))