summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2019-04-15 13:53:43 -0500
committerColin Okay <cbeok@protonmail.com>2020-10-12 09:37:42 -0500
commit2c1a879627f891183043a66949077ce4d8c70a1c (patch)
tree64f18b7a2cc4c18c70f97d5aa7daf359607d7cec
parent0a35e12dbc49067eff4c3be830e72839cd06c1b6 (diff)
convert non-rgb images to rgb for copying to tilesheet
-rwxr-xr-ximbricate.ros10
1 files changed, 7 insertions, 3 deletions
diff --git a/imbricate.ros b/imbricate.ros
index fbdf700..b25d9d1 100755
--- a/imbricate.ros
+++ b/imbricate.ros
@@ -58,15 +58,20 @@ exec ros -Q -- $0 "$@"
"fills grid with T for rectangle x y w h"
(do-over-rect x y w h #'(lambda (xi yi) (setf (aref grid xi yi) t))))
+(defun rgb-imagep (img)
+ (eq (find-class 'imago:rgb-image)
+ (class-of img)))
+
(defun pack-images (packlist)
"Creates an image and copies the contents of the packlist to that image"
(destructuring-bind (cw ch) (packlist-dimensions packlist)
(let ((tilesheet (make-instance 'imago:rgb-image :width cw :height ch)))
(dolist (spec packlist)
(let-when (img (safe-open-image (getf spec :path)))
- (imago:copy tilesheet img
+ (let ((img (if (not (rgb-imagep img)) (imago:convert-to-rgb img) img)))
+ (imago:copy tilesheet img
:dest-x (getf spec :x)
- :dest-y (getf spec :y))))
+ :dest-y (getf spec :y)))))
tilesheet)))
(defun packlist->tile-index (packlist)
@@ -134,7 +139,6 @@ exec ros -Q -- $0 "$@"
(search-loop)))
-
(defun main (&rest argv)
(declare (ignorable argv))
(destructuring-bind (path target) argv