diff options
author | Boutade <thegoofist@protonmail.com> | 2019-04-15 13:53:43 -0500 |
---|---|---|
committer | Boutade <thegoofist@protonmail.com> | 2019-04-15 13:53:43 -0500 |
commit | ed091397779cce2e6c8792825978be26878b7e50 (patch) | |
tree | 64f18b7a2cc4c18c70f97d5aa7daf359607d7cec | |
parent | 921c5a127c76c30c63451e55cbd5b0c59476a5ed (diff) |
convert non-rgb images to rgb for copying to tilesheet
-rwxr-xr-x | imbricate.ros | 10 |
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 |