[cl-gd-devel] Re: Drawing anti-aliased text with transparent background
Andrei Stebakov
lispercat at gmail.com
Sun Mar 18 03:17:21 UTC 2007
I got some help from libgd mailing list, so when I put Pierre's sample to
lisp here is what I got (solves my problem):
(with-image (new width height t)
(setf (alpha-blending-p new) nil)
(draw-rectangle* 0 0 width height :image new :filled t :color
(allocate-color 0 0 0 :image new :alpha 127))
(draw-freetype-string 0 0
text
:image new
:anti-aliased t
:font-name font
:angle 0
:point-size font-size
:color (allocate-color 0 0 255 :image new))
(setf (save-alpha-p :image new) t)
(write-image-to-file file-name :image new :if-exists :supersede)))
Thank you,
Andrew
On 3/17/07, Andrei Stebakov <lispercat at gmail.com> wrote:
>
> Ah, it looks like make-anti-aliased is only for brushes, for drawing
> lines... I wonder what technique works for the text?
>
> Thanks!
> Andrew
>
> On 3/17/07, Andrei Stebakov <lispercat at gmail.com> wrote:
> >
> > I tred to use the (make-anti-aliased) function:
> > (draw-freetype-string 0 0
> > text
> > :anti-aliased t
> > :font-name font
> > :angle 0
> > :point-size font-size
> > :color (make-anti-aliased (allocate-color 0 0 255)))
> >
> > But the lisp gives me the error:
> >
> > The value of CL-GD::COLOR is #S(CL-GD::ANTI-ALIASED-COLOR
> > :COLOR 255
> > :DO-NOT-BLEND NIL), which is not of
> > type INTEGER.
> > [Condition of type SIMPLE-TYPE-ERROR]
> >
> > Restarts:
> > 0: [STORE-VALUE] Supply a new value of CL-GD::COLOR.
> > 1: [ABORT] Return to SLIME's top level.
> > 2: [ABORT] Return to Top-Level.
> >
> > Backtrace:
> > 0: (LISP::CHECK-TYPE-ERROR CL-GD::COLOR
> > #S(CL-GD::ANTI-ALIASED-COLOR
> > :COLOR 255
> > :DO-NOT-BLEND NIL)
> > INTEGER
> > NIL)
> >
> > Thank you,
> > Andrew
> >
> > On 3/17/07, Andrei Stebakov < lispercat at gmail.com> wrote:
> > >
> > > 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/0a70985a/attachment.html>
More information about the Cl-gd-devel
mailing list