[cl-gd-devel] Drawing anti-aliased text with transparent background

Andrei Stebakov lispercat at gmail.com
Sat Mar 17 13:39:00 UTC 2007


Here is what I've got:
http://www.greenpixeldesign.com/cphandler/tmp-img/test.png
I'd like to remove the black outline from the anti-aliased text (I need RGB
true color image). I know I am missing some stupid thing, but I experimented
with different backgrounds, just doesn't make it right. My current setup is
gdlib 2.0.33 on debian, and here is the code;

(defun create-text-image (text font font-size file-name)
  (multiple-value-bind (width height horizont-shift vertical-shift)
      (get-bounding-rect text font font-size)
    (with-image* (width height t)
      (let* ((white (allocate-color 255 255 255))
         (black (allocate-color 0 0 0))
         (red (allocate-color 255 0 0))
         (green (allocate-color 0 255 0))
         (blue (allocate-color 0 0 255)))
    (setf (transparent-color) black)
    (draw-freetype-string (- 0 horizont-shift) (- height vertical-shift)
                  text
                  :anti-aliased t
                  :font-name font
                  :angle 0
                  :point-size font-size
                  :color (allocate-color 0 0 255))

    ;;(true-color-to-palette)
    (write-image-to-file file-name :if-exists :supersede)))))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cl-gd-devel/attachments/20070317/37c80dce/attachment.html>


More information about the Cl-gd-devel mailing list