X-Git-Url: http://uxul.de/gitweb/?a=blobdiff_plain;f=files.lisp;fp=files.lisp;h=9c6d44e55eedc87c642d2e5fb0d64f103675eab6;hb=3513580fa41deb8023977f77e64997708ff26455;hp=65918ae90e16f13cedf4ce6902046b91f8080434;hpb=3a5b6fe5b066ace9e3d03ec20c96c224cdbeb0b8;p=uxul-world.git diff --git a/files.lisp b/files.lisp index 65918ae..9c6d44e 100755 --- a/files.lisp +++ b/files.lisp @@ -8,27 +8,15 @@ (defun si (var val) (setf (symbol-value (intern var)) val)) - (defun stretch-image (x y img) - "Call ImageMagick to resize that file to 64x64." - (lisp-magick:with-magick-wand (mywand) - (lisp-magick::magick-read-image-blob mywand img) - (lisp-magick::magick-resize-image mywand x y #x00000000 1d0) - (lisp-magick::magick-set-format mywand "png") - (lisp-magick::magick-get-image-blob mywand))) + "Resize that file to x times y." + (uxul-world::resize-bmp-blob img x y)) (defun ash-sized-image (img a) - "Calculate an image of half of the size." - (lisp-magick:with-magick-wand (mywand) - (lisp-magick::magick-read-image-blob mywand img) - (let - ((w (lisp-magick::magick-get-image-width mywand)) - (h (lisp-magick::magick-get-image-height mywand))) - (lisp-magick::magick-resize-image mywand - (max 1 (floor (/ w a))) (max 1 (floor (/ h a))) ;; no ash here ... - #x00000000 1d0) - (lisp-magick::magick-set-format mywand "png") - (lisp-magick::magick-get-image-blob mywand)))) + "Calculate an image of half/eighth/quarter of the size." + (let ((w (bmp-width img)) + (h (bmp-height img))) + (uxul-world::resize-bmp-blob img (max 1 (floor (/ w a))) (max 1 (floor (/ h a)))))) (defun all-sizes (img) (list img @@ -36,21 +24,7 @@ (ash-sized-image img 4) (ash-sized-image img 8))) - -;; (defun init-file (file) -;; "Load a file into a Variable. Access with |filename| (without .png -;; and path)." -;; (si (pathname-name file) -;; (stretched-image -;; (with-open-file (in file :element-type '(unsigned-byte 8)) -;; (let* ((length (file-length in)) -;; (content (make-array (list length) -;; :element-type '(unsigned-byte 8) -;; :adjustable nil))) -;; (read-sequence content in) -;; content))))) - -(defun init-png-file (file) +(defun init-bmp-file (file) "Load an image file into a Variable. Set |filename| (without .png and path) to a list with all sizes of that image." (si (pathname-name file) @@ -63,18 +37,18 @@ and path) to a list with all sizes of that image." (read-sequence content in) content))))) -(defun png-p (file) +(defun bmp-p (file) "Is the file relevant for initialization? So far only .png-files are relevant." - (string= (pathname-type file) "png")) + (string= (pathname-type file) "bmp")) -(defun init-png-files () +(defun init-bmp-files () (cl-fad:walk-directory (asdf:component-pathname (asdf:find-system :uxul-world)) - #'init-png-file :test #'png-p)) + #'init-bmp-file :test #'bmp-p)) (defun init-files () "Load the relevant files into variables" - (init-png-files)) + (init-bmp-files)) (init-files) \ No newline at end of file