Skip to content

Commit

Permalink
export do-pixels and friends, clean up :: usage, get rid of some magi…
Browse files Browse the repository at this point in the history
…c numbers in gif writing
  • Loading branch information
slyrus committed Mar 14, 2011
1 parent 010958a commit 5381afb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
23 changes: 13 additions & 10 deletions gif.lisp
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions package.lisp
Expand Up @@ -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
Expand Down Expand Up @@ -44,6 +50,8 @@
#:sharpen-image
#:blur-image

#:clear-image

;; Drawing primitives
#:fill-image
#:fill-image*
Expand Down Expand Up @@ -111,6 +119,7 @@
#:convert-image-to-grayscale-luminance
#:convert-image-to-rgb
#:convert-image-to-rgba
#:convert-image-to-8-bit-grayscale

))

Expand Down
4 changes: 2 additions & 2 deletions tiff.lisp
Expand Up @@ -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

Expand Down

0 comments on commit 5381afb

Please sign in to comment.