Update of /project/trivial-freeimage/cvsroot/source In directory clnet:/tmp/cvs-serv4284
Modified Files: trivial-freeimage.lisp Added Files: defpackage.lisp trivial-freeimage.asd Log Message: Made into an asdf package. Just (asdf:oos 'asdf:load-op :cffi) (asdf:oos 'asdf:load-op :trivial-freeimage) (use-package :trivial-freeimage)
--- /project/trivial-freeimage/cvsroot/source/trivial-freeimage.lisp 2007/01/14 16:57:19 1.1 +++ /project/trivial-freeimage/cvsroot/source/trivial-freeimage.lisp 2007/01/17 04:53:15 1.2 @@ -1,99 +1,98 @@ -(defpackage :trivial-freeimage - (:use :common-lisp :cffi))
(in-package :trivial-freeimage) + (define-foreign-library freeimage (:unix "libfreeimage.so.3") - (:windows "FreeImaged.dll") + (:windows "FreeImage.dll") (t (:default "libfreeimage"))) (use-foreign-library freeimage)
-(defconstant UNKNOWN -1) -(defconstant BMP 0) -(defconstant ICO 1) -(defconstant JPEG 2) -(defconstant JNG 3) -(defconstant KOALA 4) -(defconstant LBM 5) -(defconstant IFF 5) -(defconstant MNG 6) -(defconstant PBM 7) -(defconstant PBMRAW 8) -(defconstant PCD 9) -(defconstant PCX 10) -(defconstant PGM 11) -(defconstant PGMRAW 12) -(defconstant PNG 13) -(defconstant PPM 14) -(defconstant PPMRAW 15) -(defconstant RAS 16) -(defconstant TARGA 17) -(defconstant TIFF 18) -(defconstant WBMP 19) -(defconstant PSD 20) -(defconstant CUT 21) -(defconstant XBM 22) -(defconstant XPM 23) -(defconstant DDS 24) -(defconstant GIF 25) -(defconstant HDR 26) -(defconstant FAXG3 27) -(defconstant SGI 28) - - -(defconstant BMP_DEFAULT 0) -(defconstant BMP_SAVE_RLE 1) -(defconstant CUT_DEFAULT 0) -(defconstant DDS_DEFAULT 0) -(defconstant FAXG3_DEFAULT 0) -(defconstant GIF_DEFAULT 0) -(defconstant GIF_LOAD256 1) ;Load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color -(defconstant GIF_PLAYBACK 2) ;'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading -(defconstant HDR_DEFAULT 0) -(defconstant ICO_DEFAULT 0) -(defconstant ICO_MAKEALPHA 1) ;convert to 32bpp and create an alpha channel from the AND-mask when loading -(defconstant IFF_DEFAULT 0) -(defconstant JPEG_DEFAULT 0) -(defconstant JPEG_FAST 1) -(defconstant JPEG_ACCURATE 2) -(defconstant JPEG_QUALITYSUPERB #x80) -(defconstant JPEG_QUALITYGOOD #x100) -(defconstant JPEG_QUALITYNORMAL #x200) -(defconstant JPEG_QUALITYAVERAGE #x400) -(defconstant JPEG_QUALITYBAD #x800) -(defconstant JPEG_CMYK #x1000) ;load separated CMYK "as is" (use | to combine with other flags) -(defconstant JPEG_PROGRESSIVE #x2000) ;save as a progressive-JPEG (use | to combine with other flags) -(defconstant KOALA_DEFAULT 0) -(defconstant LBM_DEFAULT 0) -(defconstant MNG_DEFAULT 0) -(defconstant PCD_DEFAULT 0) -(defconstant PCD_BASE 1) ;load the bitmap sized 768 x 512 -(defconstant PCD_BASEDIV4 2) ;load the bitmap sized 384 x 256 -(defconstant PCD_BASEDIV16 3) ;load the bitmap sized 192 x 128 -(defconstant PCX_DEFAULT 0) -(defconstant PNG_DEFAULT 0) -(defconstant PNG_IGNOREGAMMA 1) ;avoid gamma correction -(defconstant PNM_DEFAULT 0) -(defconstant PNM_SAVE_RAW 0) ;If set the writer saves in RAW format (i.e. P4, P5 or P6) -(defconstant PNM_SAVE_ASCII 1) ;If set the writer saves in ASCII format (i.e. P1, P2 or P3) -(defconstant PSD_DEFAULT 0) -(defconstant RAS_DEFAULT 0) -(defconstant SGI_DEFAULT 0) -(defconstant TARGA_DEFAULT 0) -(defconstant TARGA_LOAD_RGB888 1) ;If set the loader converts RGB555 and ARGB8888 -> RGB888. -(defconstant TIFF_DEFAULT 0) -(defconstant TIFF_CMYK #x0001) ;reads/stores tags for separated CMYK (use | to combine with compression flags) -(defconstant TIFF_PACKBITS #x0100) ;save using PACKBITS compression -(defconstant TIFF_DEFLATE #x0200) ;save using DEFLATE compression (a.k.a. ZLIB compression) -(defconstant TIFF_ADOBE_DEFLATE #x0400) ;save using ADOBE DEFLATE compression -(defconstant TIFF_NONE #x0800) ;save without any compression -(defconstant TIFF_CCITTFAX3 #x1000) ;save using CCITT Group 3 fax encoding -(defconstant TIFF_CCITTFAX4 #x2000) ;save using CCITT Group 4 fax encoding -(defconstant TIFF_LZW #x4000) ;save using LZW compression -(defconstant TIFF_JPEG #x8000) ;save using JPEG compression -(defconstant WBMP_DEFAULT 0) -(defconstant XBM_DEFAULT 0) -(defconstant XPM_DEFAULT 0) +(defconstant +UNKNOWN+ -1) +(defconstant +BMP+ 0) +(defconstant +ICO+ 1) +(defconstant +JPEG+ 2) +(defconstant +JNG+ 3) +(defconstant +KOALA+ 4) +(defconstant +LBM+ 5) +(defconstant +IFF+ 5) +(defconstant +MNG+ 6) +(defconstant +PBM+ 7) +(defconstant +PBMRAW+ 8) +(defconstant +PCD+ 9) +(defconstant +PCX+ 10) +(defconstant +PGM+ 11) +(defconstant +PGMRAW+ 12) +(defconstant +PNG+ 13) +(defconstant +PPM+ 14) +(defconstant +PPMRAW+ 15) +(defconstant +RAS+ 16) +(defconstant +TARGA+ 17) +(defconstant +TIFF+ 18) +(defconstant +WBMP+ 19) +(defconstant +PSD+ 20) +(defconstant +CUT+ 21) +(defconstant +XBM+ 22) +(defconstant +XPM+ 23) +(defconstant +DDS+ 24) +(defconstant +GIF+ 25) +(defconstant +HDR+ 26) +(defconstant +FAXG3+ 27) +(defconstant +SGI+ 28) + + +(defconstant +BMP_DEFAULT+ 0) +(defconstant +BMP_SAVE_RLE+ 1) +(defconstant +CUT_DEFAULT+ 0) +(defconstant +DDS_DEFAULT+ 0) +(defconstant +FAXG3_DEFAULT+ 0) +(defconstant +GIF_DEFAULT+ 0) +(defconstant +GIF_LOAD256+ 1) ;Load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color +(defconstant +GIF_PLAYBACK+ 2) ;'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading +(defconstant +HDR_DEFAULT+ 0) +(defconstant +ICO_DEFAULT+ 0) +(defconstant +ICO_MAKEALPHA+ 1) ;convert to 32bpp and create an alpha channel from the AND-mask when loading +(defconstant +IFF_DEFAULT+ 0) +(defconstant +JPEG_DEFAULT+ 0) +(defconstant +JPEG_FAST+ 1) +(defconstant +JPEG_ACCURATE+ 2) +(defconstant +JPEG_QUALITYSUPERB+ #x80) +(defconstant +JPEG_QUALITYGOOD+ #x100) +(defconstant +JPEG_QUALITYNORMAL+ #x200) +(defconstant +JPEG_QUALITYAVERAGE+ #x400) +(defconstant +JPEG_QUALITYBAD+ #x800) +(defconstant +JPEG_CMYK+ #x1000) ;load separated CMYK "as is" (use | to combine with other flags) +(defconstant +JPEG_PROGRESSIVE+ #x2000) ;save as a progressive-JPEG (use | to combine with other flags) +(defconstant +KOALA_DEFAULT+ 0) +(defconstant +LBM_DEFAULT+ 0) +(defconstant +MNG_DEFAULT+ 0) +(defconstant +PCD_DEFAULT+ 0) +(defconstant +PCD_BASE+ 1) ;load the bitmap sized 768 x 512 +(defconstant +PCD_BASEDIV4+ 2) ;load the bitmap sized 384 x 256 +(defconstant +PCD_BASEDIV16+ 3) ;load the bitmap sized 192 x 128 +(defconstant +PCX_DEFAULT+ 0) +(defconstant +PNG_DEFAULT+ 0) +(defconstant +PNG_IGNOREGAMMA+ 1) ;avoid gamma correction +(defconstant +PNM_DEFAULT+ 0) +(defconstant +PNM_SAVE_RAW+ 0) ;If set the writer saves in RAW format (i.e. P4, P5 or P6) +(defconstant +PNM_SAVE_ASCII+ 1) ;If set the writer saves in ASCII format (i.e. P1, P2 or P3) +(defconstant +PSD_DEFAULT+ 0) +(defconstant +RAS_DEFAULT+ 0) +(defconstant +SGI_DEFAULT+ 0) +(defconstant +TARGA_DEFAULT+ 0) +(defconstant +TARGA_LOAD_RGB888+ 1) ;If set the loader converts RGB555 and ARGB8888 -> RGB888. +(defconstant +TIFF_DEFAULT+ 0) +(defconstant +TIFF_CMYK+ #x0001) ;reads/stores tags for separated CMYK (use | to combine with compression flags) +(defconstant +TIFF_PACKBITS+ #x0100) ;save using PACKBITS compression +(defconstant +TIFF_DEFLATE+ #x0200) ;save using DEFLATE compression (a.k.a. ZLIB compression) +(defconstant +TIFF_ADOBE_DEFLATE+ #x0400) ;save using ADOBE DEFLATE compression +(defconstant +TIFF_NONE+ #x0800) ;save without any compression +(defconstant +TIFF_CCITTFAX3+ #x1000) ;save using CCITT Group 3 fax encoding +(defconstant +TIFF_CCITTFAX4+ #x2000) ;save using CCITT Group 4 fax encoding +(defconstant +TIFF_LZW+ #x4000) ;save using LZW compression +(defconstant +TIFF_JPEG+ #x8000) ;save using JPEG compression +(defconstant +WBMP_DEFAULT+ 0) +(defconstant +XBM_DEFAULT+ 0) +(defconstant +XPM_DEFAULT+ 0)
(defcstruct bitmapinfoheader (bisize :unsigned-long) @@ -115,9 +114,6 @@ (bmiheader bitmapinfoheader) (bmicolors :pointer))
- - - (defcfun ("FreeImage_Initialise" initialize) :void (plugin :boolean))
@@ -127,20 +123,26 @@
(defcfun ("FreeImage_GetCopyrightMessage" get-copyright-message) :string)
+ + (defcfun ("FreeImage_Load" load-image) :pointer (fif :int) (filename :string) (flags :int))
+ (setf *current-dib* (freeimage-load (get-file-type file-name 0) file-name flags)) + (defcfun ("FreeImage_Unload" unload-image) :void (dib :pointer))
+ (defcfun ("FreeImage_Save" save-image) :int (fif :int) (dib :pointer) (filename :string) (flags :int))
+ (defcfun ("FreeImage_Clone" clone-image) :pointer (dib :pointer))
@@ -442,7 +444,15 @@ (right :int) (bottom :int))
- - - - +(defmacro with-dib ((dib-var file-name + &key (file-type-arg 0) (load-image-arg 0)) + &body body) + `(let ((,dib-var nil)) + (unwind-protect + (progn + (setf ,dib-var (load-image (get-file-type ,file-name ,file-type-arg) ,file-name + ,load-image-arg)) + ,@body) + (when ,dib-var + (unload-image ,dib-var))))) + \ No newline at end of file
--- /project/trivial-freeimage/cvsroot/source/defpackage.lisp 2007/01/17 04:53:15 NONE +++ /project/trivial-freeimage/cvsroot/source/defpackage.lisp 2007/01/17 04:53:15 1.1 ;;;; 2007-01-15 10:22:27
(in-package :common-lisp-user)
(defpackage :trivial-freeimage (:nicknames :trivial-freeimage) (:use :cl :cffi) (:export :load-image :with-dib :save-image :copy :paste :initialize :de-initialize :get-version :get-copyright-information :unload-image :clone-image :get-image-type :get-info-header :get-info :get-height :get-width :get-bpp :get-colors-used :get-pitch :get-line :get-dib-size :get-scan-line :get-dots-per-meter-x :get-dots-per-meter-y :set-dots-per-meter-x :set-dots-per-meter-y :get-blue-mask :get-red-mask :get-green-mask :get-transparency-count :get-transparency-table :set-transparency-table :set-transparent :is-transparent :has-background-color :get-background-color :set-background-color :get-bits :get-file-type :get-pixel-index :get-pixel-color :set-pixel-index :set-pixel-color :convert-to-4-bits :convert-to-8-bits :convert-to-24-bits :convert-to-32-bits :convert-to-greyscale :convert-to-16-bits-555 :convert-to-16-bits-565 :color-quantize :color-quantize-ex :convert-from-raw-bits :convert-to-raw-bits :dither :threshold :convert-to-rgbf :convert-to-standard-type :convert-to-type :rotate-classic :rotate-ex :flip-vertical :flip-horizontal :adjust-brightness :adjust-curve :adjust-gamma :adjust-contrast :invert :jpeg-transform :rescale :make-thumbnail :composite :jpeg-crop :get-channel :set-channel :get-complex-channel :set-complex-channel :get-histogram :+UNKNOWN+ :+BMP+ :+ICO+ :+JPEG+ :+JNG+ :+KOALA+ :+LBM+ :+IFF+ :+MNG+ :+PBM+ :+PBMRAW+ :+PCD+ :+PCX+ :+PGM+ :+PGMRAW+ :+PNG+ :+PPM+ :+PPMRAW+ :+RAS+ :+TARGA+ :+TIFF+ :+WBMP+ :+PSD+ :+CUT+ :+XBM+ :+XPM+ :+DDS+ :+GIF+ :+HDR+ :+FAXG3+ :+SGI+ :+BMP_DEFAULT+ :+BMP_SAVE_RLE+ :+CUT_DEFAULT+ :+DDS_DEFAULT+ :+FAXG3_DEFAULT+ :+GIF_DEFAULT+ :+GIF_LOAD256+ :+GIF_PLAYBACK+ :+HDR_DEFAULT+ :+ICO_DEFAULT+ :+ICO_MAKEALPHA+ :+IFF_DEFAULT+ :+JPEG_DEFAULT+ :+JPEG_FAST+ :+JPEG_ACCURATE+ :+JPEG_QUALITYSUPERB+ :+JPEG_QUALITYGOOD+ :+JPEG_QUALITYNORMAL+ :+JPEG_QUALITYAVERAGE+ :+JPEG_QUALITYBAD+ :+JPEG_CMYK+ :+JPEG_PROGRESSIVE+ :+KOALA_DEFAULT+ :+LBM_DEFAULT+ :+MNG_DEFAULT+ :+PCD_DEFAULT+ :+PCD_BASE+ :+PCD_BASEDIV4+ :+PCD_BASEDIV16+ :+PCX_DEFAULT+ :+PNG_DEFAULT+ :+PNG_IGNOREGAMMA+ :+PNM_DEFAULT+ :+PNM_SAVE_RAW+ :+PNM_SAVE_ASCII+
[21 lines skipped] --- /project/trivial-freeimage/cvsroot/source/trivial-freeimage.asd 2007/01/17 04:53:15 NONE +++ /project/trivial-freeimage/cvsroot/source/trivial-freeimage.asd 2007/01/17 04:53:15 1.1
[34 lines skipped]
trivial-freeimage-cvs@common-lisp.net