Hi,

You can generate your image on an AWT graphics surface on the server, and
use standard AWT drawing techniques, or Java2D, to make more complex images.
You then need to serialise your image to a binary stream to send to the
client.

This can cause problems if your server doesn't have a graphical environment.
Even though you can create graphics without popping up windows on the
server, some graphics methods require that the host (the server) has a GUI:
not generally a problem with Windows, but on a Linux/UNIX server, you need
an X-Server or an emulation of an X-Server ... unless you're using JDK1.4,
which provides "headless" mode (to create server-side graphics without an
X-Server).

To send your nice anti-aliased text images to the client, you need to set
the appropriate content type (such as "image/png") and use an output stream
for the servlet response.  To encode your images to the output stream, you
can install the JAI (Java Advanced Imaging) API from Sun along with your
JDK, which provides these methods, or if you're using JDK1.4, you could try
the Image I/O API (included as standard) ; I haven't tried the latter, but
it should work.

Finally, creating such images demands a lot of resources (relatively
speaking).  You're best to try and cache the images to disk whenever you
create them, and only replace them if the text to display changes.  For
subsequent requests, just copy the cached image to the output stream (by
reading from an InputStream that points to the file in the cache).

I've no example code unfortunately, but it is reasonably straightforward.

-Chris

----- Original Message -----
From: "Marc Elliott" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Friday, May 03, 2002 6:36 PM
Subject: Anti-Alias Font Images on the Fly?


Hello folks,

Do any of you know of a JSP/javabean/apache solution to generating nice
anti-alias type image on the fly.  I'm just sick to death of continually
cutting and re-cutting images because

1 -- a designer won't work with HTML type faces and
2 -- the the textual content keeps changing

I also have an application for building web sites in which I'd like to offer
the option of changing the pretty graphic type to the user.

Any thoughts?

Thanks!

Marc





--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to