From ed091397779cce2e6c8792825978be26878b7e50 Mon Sep 17 00:00:00 2001 From: Boutade Date: Mon, 15 Apr 2019 13:53:43 -0500 Subject: convert non-rgb images to rgb for copying to tilesheet --- imbricate.ros | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'imbricate.ros') 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 -- cgit v1.2.3