Works again.
[uxul-world.git] / bmp.lisp
index 3597045..d6c5471 100755 (executable)
--- a/bmp.lisp
+++ b/bmp.lisp
@@ -126,6 +126,18 @@ all."
          (setf (elt dst-blob (+ i dst-pos))\r
                (elt src-blob (+ i src-pos))))))))\r
 \r
+(defun sub-image (x y width height source-blob source-width source-height)\r
+  (create-bmp-image\r
+   width height\r
+   (lambda (pixels)\r
+     (do ((cx 0 (1+ cx))) ((= cx width))\r
+       (do ((cy 0 (1+ cy))) ((= cy height))\r
+        (let ((dst-pos (* 4 (+ cx (* cy width))))\r
+              (src-pos (* 4 (+ cx x (* (+ cy y) source-width)))))\r
+          (do ((i 0 (1+ i))) ((= i 4))\r
+            (setf (elt pixels (+ i dst-pos))\r
+                  (elt source-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