diff --git a/gif.lisp b/gif.lisp index 16a8902..2aada6e 100644 --- a/gif.lisp +++ b/gif.lisp @@ -53,20 +53,23 @@ (* (round (/ b (/ max-val (1- b-levels)))) (/ max-val (1- b-levels))))) +(defparameter *red-levels* 6) +(defparameter *green-levels* 6) +(defparameter *blue-levels* 6) + (defun 8-bit-rgb-image-to-skippy-image (image color-table) (with-image-bounds (height width) image (let ((gif-image (skippy:make-image :height height :width width))) - (let ((color-map (uniform-color-map 6 6 6))) - (do-pixels (i j) image - (multiple-value-bind (r g b) - (pixel image i j) - (multiple-value-bind (assigned-r assigned-g assigned-b) - (assign-color r g b 6 6 6) - (let ((color-index (skippy:ensure-color - (skippy:rgb-color assigned-r assigned-g assigned-b) - color-table))) - (setf (skippy:pixel-ref gif-image j i) color-index)))))) + (do-pixels (i j) image + (multiple-value-bind (r g b) + (pixel image i j) + (multiple-value-bind (assigned-r assigned-g assigned-b) + (assign-color r g b *red-levels* *green-levels* *blue-levels*) + (let ((color-index (skippy:ensure-color + (skippy:rgb-color assigned-r assigned-g assigned-b) + color-table))) + (setf (skippy:pixel-ref gif-image j i) color-index))))) gif-image))) (defun write-gif-stream (stream image) diff --git a/package.lisp b/package.lisp index 1ecb98c..b999e9b 100644 --- a/package.lisp +++ b/package.lisp @@ -9,6 +9,12 @@ #:pixel #:pixel* + #:do-pixels + #:set-pixels + + #:do-region-pixels + #:set-region-pixels + #:1-bit-gray-image #:make-1-bit-gray-image #:2-bit-gray-image #:make-2-bit-gray-image #:4-bit-gray-image #:make-4-bit-gray-image @@ -44,6 +50,8 @@ #:sharpen-image #:blur-image + #:clear-image + ;; Drawing primitives #:fill-image #:fill-image* @@ -111,6 +119,7 @@ #:convert-image-to-grayscale-luminance #:convert-image-to-rgb #:convert-image-to-rgba + #:convert-image-to-8-bit-grayscale )) diff --git a/tiff.lisp b/tiff.lisp index 9ee0fca..662d96f 100644 --- a/tiff.lisp +++ b/tiff.lisp @@ -15,8 +15,8 @@ image or an 8-bit grayscale image" (samples-per-pixel tiff:tiff-image-samples-per-pixel) (bits-per-sample tiff:tiff-image-bits-per-sample) (image-data tiff:tiff-image-data) - (color-map tiff::tiff-image-color-map) - (min-is-white tiff::tiff-image-min-is-white)) + (color-map tiff:tiff-image-color-map) + (min-is-white tiff:tiff-image-min-is-white)) tiff-image (cond