From f4749c96ca3771e0d1717493098c6af47e304967 Mon Sep 17 00:00:00 2001 From: Julian Squires Date: Sat, 19 Dec 2009 18:16:12 -0500 Subject: [PATCH] Added some palette-related functions and a couple of simple accessor utilities. --- il.lisp | 13 ++++++++++++- package.lisp | 5 +++++ utilities.lisp | 20 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/il.lisp b/il.lisp index c31d3f7..7c24f54 100644 --- a/il.lisp +++ b/il.lisp @@ -65,6 +65,15 @@ (:float #x1406) (:double #x140A)) +(defcenum palette-type + (:none #x0400) + (:rgb24 #x0401) + (:rgb32 #x0402) + (:rgba32 #x0403) + (:bgr24 #x0404) + (:bgr32 #x0405) + (:bgra32 #x0406)) + (defcenum error (:no-error #x0000) (:invalid-enum #x0501) @@ -167,6 +176,7 @@ (defcfun ("ilKeyColour" key-color) :void (red :float) (green :float) (blue :float) (alpha :float)) (defcfun ("ilGetPalette" get-palette) :pointer) +(defcfun ("ilRegisterPal" register-palette) :void (palette :pointer) (size :uint) (type palette-type)) (defcfun ("ilGetInteger" get-integer) :uint (mode mode)) (defcfun ("ilSetInteger" set-integer) :void (mode mode) (param :int)) @@ -177,4 +187,5 @@ (defcfun ("ilConvertImage" convert-image) :boolean (format data-format) (type data-type)) (defcfun ("ilFlipImage" flip-image) :boolean) -(defcfun ("ilDetermineType" determine-type) image-type (pathname pathname-string)) \ No newline at end of file +(defcfun ("ilDetermineType" determine-type) image-type (pathname pathname-string)) + diff --git a/package.lisp b/package.lisp index af0c509..a2cb81b 100644 --- a/package.lisp +++ b/package.lisp @@ -9,6 +9,10 @@ #:with-init #:width-of #:height-of + #:pixel-format-of + #:element-type-of + #:bytes-per-pixel-of + #:copy-palette ;; bindings #:BIND-IMAGE #:BLIT @@ -26,6 +30,7 @@ #:GET-ERROR #:GET-INTEGER #:GET-PALETTE + #:REGISTER-PALETTE #:INIT #:IS-ENABLED #:KEY-COLOR diff --git a/utilities.lisp b/utilities.lisp index 5a1917f..c14303f 100644 --- a/utilities.lisp +++ b/utilities.lisp @@ -42,6 +42,26 @@ (bind-image id) (get-integer :image-height)) +(defun pixel-format-of (id) + (bind-image id) + (foreign-enum-keyword 'data-format (get-integer :image-format))) + +(defun element-type-of (id) + (bind-image id) + (foreign-enum-keyword 'data-type (get-integer :image-type))) + +(defun bytes-per-pixel-of (id) + (bind-image id) + (get-integer :image-bytes-per-pixel)) + +(defun copy-palette (dest src) + (bind-image src) + (let ((type (get-integer :palette-type)) + (ncols (get-integer :palette-num-cols)) + (bpp (get-integer :palette-bpp)) + (pointer (get-palette))) + (bind-image dest) + (register-palette pointer (* ncols bpp) type))) (defun gen-images (n) (with-foreign-object (ids :uint n) -- 2.11.4.GIT