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))
11 (defun stretch-image (x y img)
12 "Resize that file to x times y."
13 (uxul-world::resize-bmp-blob img x y))
15 (defun ash-sized-image (img a)
16 "Calculate an image of half/eighth/quarter of the size."
17 (let ((w (bmp-width img))
19 (uxul-world::resize-bmp-blob img (max 1 (floor (/ w a))) (max 1 (floor (/ h a))))))
21 (defun all-sizes (img)
23 (ash-sized-image img 2)
24 (ash-sized-image img 4)
25 (ash-sized-image img 8)))
27 (defun init-bmp-file (file)
28 "Load an image file into a Variable. Set |filename| (without .png
29 and path) to a list with all sizes of that image."
30 (si (pathname-name file)
32 (with-open-file (in file :element-type '(unsigned-byte 8))
33 (let* ((length (file-length in))
34 (content (make-array (list length)
35 :element-type '(unsigned-byte 8)
37 (read-sequence content in)
41 "Is the file relevant for initialization? So far only .png-files are
43 (string= (pathname-type file) "bmp"))
45 (defun init-bmp-files ()
46 (cl-fad:walk-directory
47 (asdf:component-pathname (asdf:find-system :uxul-world))
48 #'init-bmp-file :test #'bmp-p))
51 "Load the relevant files into variables"