Creating a spritesheet instead of many surfaces.
[uxul-world.git] / bmp.lisp
index 24ba92e..3597045 100755 (executable)
--- a/bmp.lisp
+++ b/bmp.lisp
@@ -115,6 +115,17 @@ all."
                    :displaced-index-offset o)\r
        (subseq sequence o (+ o l)))))\r
 \r
+(defun blit-image (x y src-width src-height src-blob\r
+                  dst-width dst-height dst-blob)\r
+  (declare (ignore dst-height))\r
+  (do ((cx 0 (1+ cx))) ((= cx src-width))\r
+    (do ((cy 0 (1+ cy))) ((= cy src-height))\r
+      (let ((src-pos (* 4 (+ cx (* cy src-width))))\r
+           (dst-pos (* 4 (+ (+ x cx) (* (+ y cy) dst-width)))))\r
+       (do ((i 0 (1+ i))) ((= i 4))\r
+         (setf (elt dst-blob (+ i dst-pos))\r
+               (elt src-blob (+ i src-pos))))))))\r
+\r
 (defun resize-pixeldata\r
     (argb-pixeldata old-width old-height new-width new-height\r
      &optional (new-pixeldata (make-array (list (* 4 new-width new-height))\r