Hi Everybody,
I am trying to create dynamic images in a JSP. I have downloaded
Acme GIF Encoder and trying to create images from the Servlets & JSPs but I
am facing few problems. First of all, when I create a simple image it shows
with a blue screen on top of the image due to which the colors of my image
are not correct. My question is whether I can change this thing so that my
image comes with original colors without any blue screen on top of it. I
also tried to create an image in a JSP but no luck. Please help me out and
let me know where I am doing wrong. The code for my JSP looks like that:
<html>
<head><title>Test</title></head>
<body>
<% java.awt.Frame frame = null;
java.awt.Graphics g = null;
java.io.FileOutputStream fileOut = null;
try
{
//create an unshown frame
frame = new java.awt.Frame();
frame.addNotify();
//get a graphics region, using the frame
java.awt.Image image = frame.createImage(100, 100);
g = image.getGraphics();
//manipulate the image
g.drawString("Hello world", 0, 0);
response.setContentType("image/gif");
//get an ouputstream to a file
fileOut = new java.io.FileOutputStream("Test.gif");
Acme.JPM.Encoders.GifEncoder encoder = new
Acme.JPM.Encoders.GifEncoder(image, fileOut);
//Acme.JPM.Encoders.JpegEncoder encoder = new
Acme.JPM.Encoders.JpegEncoder(image, fileOut);
encoder.encode();
}
catch (Exception e)
{}
finally
{
//clean up
if (g != null)
g.dispose();
if (frame != null)
frame.removeNotify();
if (fileOut != null)
{
try { fileOut.close(); }
catch (IOException ioe) { }
}
}
%>
Testing Dynamic Images
<img src="Test.gif" width="300" height="100">
</body>
</html>
I will be geatful to you if you let me know what I am doing wrong. Thanks
again.
Babar Bhutta.
Aptis Software, Austin, TX
(800)460-9701 ext 4123
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets