1 ;;; Copyright 2009 Christoph Senjak
3 ;; This file declares the constants for loading different files and
6 (in-package :uxul-world)
9 (setf (symbol-value (intern var)) val))
12 (defun stretch-image (x y img)
13 "Call ImageMagick to resize that file to 64x64."
14 (lisp-magick:with-magick-wand (mywand)
15 (lisp-magick::magick-read-image-blob mywand img)
16 (lisp-magick::magick-resize-image mywand x y #x00000000 1d0)
17 (lisp-magick::magick-set-format mywand "png")
18 (lisp-magick::magick-get-image-blob mywand)))
20 (defun ash-sized-image (img a)
21 "Calculate an image of half of the size."
22 (lisp-magick:with-magick-wand (mywand)
23 (lisp-magick::magick-read-image-blob mywand img)
25 ((w (lisp-magick::magick-get-image-width mywand))
26 (h (lisp-magick::magick-get-image-height mywand)))
27 (lisp-magick::magick-resize-image mywand
28 (max 1 (floor (/ w a))) (max 1 (floor (/ h a))) ;; no ash here ...
30 (lisp-magick::magick-set-format mywand "png")
31 (lisp-magick::magick-get-image-blob mywand))))
33 (defun all-sizes (img)
35 (ash-sized-image img 2)
36 (ash-sized-image img 4)
37 (ash-sized-image img 8)))
40 ;; (defun init-file (file)
41 ;; "Load a file into a Variable. Access with |filename| (without .png
43 ;; (si (pathname-name file)
45 ;; (with-open-file (in file :element-type '(unsigned-byte 8))
46 ;; (let* ((length (file-length in))
47 ;; (content (make-array (list length)
48 ;; :element-type '(unsigned-byte 8)
50 ;; (read-sequence content in)
53 (defun init-png-file (file)
54 "Load an image file into a Variable. Set |filename| (without .png
55 and path) to a list with all sizes of that image."
56 (si (pathname-name file)
58 (with-open-file (in file :element-type '(unsigned-byte 8))
59 (let* ((length (file-length in))
60 (content (make-array (list length)
61 :element-type '(unsigned-byte 8)
63 (read-sequence content in)
67 "Is the file relevant for initialization? So far only .png-files are
69 (string= (pathname-type file) "png"))
71 (defun init-png-files ()
72 (cl-fad:walk-directory
73 (asdf:component-pathname (asdf:find-system :uxul-world))
74 #'init-png-file :test #'png-p))
77 "Load the relevant files into variables"