Gabriel Ciuloaica <[EMAIL PROTECTED]> wrote:
>
> Where can I find an example of creating run-time images from a servlet, or
> what are the principles ?
I don't know of any example of servlets doing that, but I worked a little
bit on dynamic images generation.
First of all you need to make sure you have a proper rendering environment
(in Windows it's not a problem, but in Unix your JVM must be able to connect
to the Xwindows server to be able to start the AWT).
In JDK 1.2 there's the BufferedImage class, check it out, as it permits to
get a "virtual" image, or better, a image that resides on memory but is not
printed on the screen.
Draw on the BufferedImage as you would do with any AWT component, and then
use something to translate the BufferedImage into a stream of bytes.
If JPEG is fine for you, it all comes in JDK 1.2 as an extension (check out
the documentation of JDK, there's a part detailing a JPEG encoder). If you
want to use GIFs, I suggest using the ACME gif package (but you might end up
with some patent infringement problems), or for PNG use the JAI (Java
Advanced Imaging API).
Usually, all those packages can write the image out to an OutputStream, and
from your servlet, simply specify your ServletOutputStream, of course
setting the appropriate content-type for the image type you want to
generate.
Pier
--
Pier Fumagalli - Sun Microsystems Inc. - <mailto:[EMAIL PROTECTED]>
----------------------------------------------------------------------------
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html