|
Revision 229, 0.8 kB
(checked in by hans, 4 years ago)
|
Utility zum Bilder zerschneiden
|
- Property svn:eol-style set to
native
- Property svn:keywords set to
author date id revision
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
(in-package :cl-user) |
|---|
| 3 |
(use-package :cl-gd) |
|---|
| 4 |
(use-package :cl-interpol) |
|---|
| 5 |
(enable-interpol-syntax) |
|---|
| 6 |
|
|---|
| 7 |
(defun make-tiles (input-filename &key (coord-width 5) (x-offset 0) (y-offset 0) (tile-size 100) (output-prefix "tiles/tile-")) |
|---|
| 8 |
(with-image-from-file (input-image input-filename) |
|---|
| 9 |
(loop for x from 0 below (image-width input-image) by tile-size |
|---|
| 10 |
do (format t "~&~a: " x) |
|---|
| 11 |
do (loop for y from 0 below (image-height input-image) by tile-size |
|---|
| 12 |
for tile-filename = (format nil #?"~a~$(coord-width),'0D-~$(coord-width),'0D.png" |
|---|
| 13 |
output-prefix (+ x-offset x) (+ y-offset y)) |
|---|
| 14 |
do (princ #\.) (finish-output) |
|---|
| 15 |
do (with-image (tile tile-size tile-size) |
|---|
| 16 |
(copy-image input-image tile x y 0 0 tile-size tile-size) |
|---|
| 17 |
(write-image-to-file tile-filename |
|---|
| 18 |
:image tile |
|---|
| 19 |
:if-exists :supersede)))))) |
|---|