diff --git a/il.lisp b/il.lisp index 33271b5..f463ff4 100644 --- a/il.lisp +++ b/il.lisp @@ -245,6 +245,10 @@ (deferrwrap flip-image)) (defcfun ("ilDetermineType" determine-type) image-type (pathname pathname-string)) +(defcfun ("ilClearColour" clear-colour) :void + (red :uint8) (green :uint8) (blue :uint8) (alpha :uint8)) +(defcfun ("ilClearImage" %clear-image) :boolean) +(deferrwrap clear-image) (defun check-error () (let ((error (get-error))) diff --git a/ilu.lisp b/ilu.lisp index ebc64a7..9d52e5f 100644 --- a/ilu.lisp +++ b/ilu.lisp @@ -46,6 +46,27 @@ (:image-origin #x0DFE) (:image-channels #x0DFF)) +(defcenum img-param-name + (:filter #x2600) + (:placement #x700)) + +(defcenum img-param + (:bilinear #x2603) + (:linear #x2602) + (:nearest #x2601) + (:scale-bell #x2606) + (:scale-box #x2604) + (:scale-bspline #x2607) + (:scale-lanczos3 #x2608) + (:scale-mitchell #x2609) + (:scale-triangle #x2605) + (:center #x705) + (:lower-left #x701) + (:lower-right #x702) + (:upper-left #x703) + (:upper-right #x704)) + + (defcfun ("iluInit" init) :void) (defcfun ("iluAlienify" %alienify) :boolean) @@ -88,7 +109,8 @@ ;; (defcfun ("iluGetImageInfo" get-image-info) :void (info :pointer)) (defcfun ("iluGetInteger" get-integer) :int (mode mode)) ;; (defcfun ("iluGetString" get-string) :string) -;; (defcfun ("iluImageParameter" image-parameter) :void (pname pname) (param param)) +(defcfun ("iluImageParameter" image-parameter) :void + (pname img-param-name) (param img-param)) (defcfun ("iluInvertAlpha" %invert-alpha) :boolean) (deferrwrap invert-alpha) (defcfun ("iluMirror" %mirror) :boolean) diff --git a/package.lisp b/package.lisp index 0cae89b..c767f51 100644 --- a/package.lisp +++ b/package.lisp @@ -28,6 +28,7 @@ #:image-bits-per-pixel #:image-origin #:copy-palette + #:clear-colour #:clear-image ;; bindings #:BIND-IMAGE @@ -134,7 +135,7 @@ :swap-colors ;; :get-image-info ;; :get-string - ;; :image-parameter + :image-parameter )) (defpackage #:ilut diff --git a/utilities.lisp b/utilities.lisp index e324247..13f312e 100644 --- a/utilities.lisp +++ b/utilities.lisp @@ -94,47 +94,3 @@ (pointer (get-palette))) (bind-image dest) (register-palette pointer (* ncols bpp) type))) - -; The standard C lib is loaded by default. I'm not entirely sure where to put -; the following: -(defcfun ("memset" memset) :pointer - (dest :pointer) (value :int) (size :unsigned-int)) - -(defcfun ("memcpy" memcpy) :pointer - (dest :pointer) (src :pointer) (size :unsigned-int)) - -(defun clear-image (&rest channel-values) - "Clears the bound image by setting the channel values for all pixels." - (let* ((iterator (get-data)) - (data iterator) - (bytes-per-pixel (get-integer :image-bytes-per-pixel)) - (width (get-integer :image-width)) - (height (get-integer :image-height)) - (data-type (ecase (foreign-enum-keyword - 'data-type (get-integer :image-type)) - (:byte :int8) - (:double :double) - (:float :float) - (:int :int) - (:short :short) - (:unsigned-int :unsigned-int) - (:unsigned-byte :uint8) - (:unsigned-short :unsigned-short))) - (data-type-size (foreign-type-size data-type)) - (row-size (* width bytes-per-pixel))) - (assert (= (* data-type-size (length channel-values)) bytes-per-pixel) () - "incorrect channel count") - (if (apply #'= (cons 0 channel-values)) - (memset data 0 (* width height bytes-per-pixel)) - (with-foreign-object (src-pixel :uint8 bytes-per-pixel) - (let ((iterator src-pixel)) - (dolist (channel channel-values) - (setf (mem-aref iterator data-type) - channel) - (incf-pointer iterator data-type-size))) - (dotimes (i width) - (memcpy iterator src-pixel bytes-per-pixel) - (incf-pointer iterator bytes-per-pixel)) - (dotimes (i (1- height)) - (memcpy iterator data row-size) - (incf-pointer iterator row-size))))))