[cl-gd-devel] [question] change of colors when tiling an image
colimal at mails.selgrad.org
colimal at mails.selgrad.org
Thu Mar 11 17:29:21 UTC 2010
Hello all :)
I'm using cl-gd to generate tiles of a larger image. I'm generating a set of
tiles of each, e.g. 256x256 pixels, from an input image that is much larger,
e.g. 4096x2048.
When using "debug-images" (pngs) with few colors and large areas of the same
color this works well. However, when I want to tile a png file with higher
frequencies and lots of colors the resulting tile images seem to be resampled
somehow, with a huge loss of quality.
Here is part of my code:
(with-image-from-file (src input-name)
(let ((width (image-width src))
(height (image-height src)))
;; store a single tile
(defun generate-tile (x y)
"Generates a single tile. The index of which is given in x and y"
(with-image (dest size size)
(copy-image src dest (* x size) (* y size) 0 0 size size)
(write-image-to-file (concatenate 'string output-base "-" (write-to-string x) "-" (write-to-string y) "." ext)
:image dest :if-exists :supersede :compression-level 0)))
;; master's actual code
(let ((count-x (ceiling (/ width size)))
(count-y (ceiling (/ height size))))
(format t "Slicing up ~s (~d x ~d) into (~d x ~d) tiles of size (~d x ~d).~%" input-name width height count-x count-y size size)
(dotimes (x count-x)
(dotimes (y count-y)
(generate-tile x y))))))
As you can see, I don't compress the image (doesn't change, if I leave the
compression key out), and only copy a given section to the output image.
The version of cl-gd I'm using is 0.5.7, the version of is libgd 2.0.0.
I would appreciate if someone would hint me to what I'm missing :)
Thanks in advance,
Kai.
More information about the Cl-gd-devel
mailing list