Sorry if this is too far off topic, but... :-)
Is anyone out there familiar with editing images on the fly? I currently
have the servlet loading an image from a url and then sending it to the
browser as image/jpeg. I would like to be able to add text to the image
before sending the image to the browser.
I'm using the GLF library from Sun to do all of the encoding etc... like I
said, the image makes it to the browser, but the text isn't there...
the code in question...
ServletOutputStream out = response.getOutputStream();
JPEGEncoder myencoder = new JPEGEncoder();
Toolbox mytoolbox = new Toolbox();
float x1 = 0;
float y1 = 0;
try {
URL imageURL = new URL("http://myserver/images/image.jpg");
BufferedImage myImage = Toolbox.loadJPEGImage(imageURL);
Graphics2D g = myImage.createGraphics();
//do i really need these?
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
g.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
//?
FontRenderContext frc = g.getFontRenderContext();
Font defaultfont = new Font("Arial", Font.PLAIN, 14);
g.setColor(Color.red);
TextLayout tl = new TextLayout(message, defaultfont, frc);
tl.draw(g, x1, y1);
response.setContentType("image/jpeg");
//i've tried myencoder.encode(g, out); but got the
//same results...
myencoder.encode(myImage, out);
out.close();
} catch (MalformedURLException mue) {
response.setContentType("text/html");
//ServletOutputStream out = response.getOutputStream();
out.println(mue.getMessage());
}
___________________________________________________________________________
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