Article View: borland.public.jbuilder.java.language
Article #7548Re: Dynamic Images in Servlets
From: Ravi
Date: Tue, 05 Jun 2001 20:54
Date: Tue, 05 Jun 2001 20:54
32 lines
2294 bytes
2294 bytes
LeRoux, using com.sun.image.codec.jpeg.* package, here is how you can do it :
Create a java.awt.Image object, get a Graphics object from it.
Draw on this graphics object. Create an encoder for the outgoing
response and encode the image.
Image image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
graph = image.createGraphics();
// Draw onto this Graph object whatever you like.
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder
(response.getOutputStream());
encoder.encode (image);
That should do it!
Ravi
"LeRoux van Wyk" <lrvw@maties.sun.ac.za> wrote in message news:<9ffjil$2k3c$1@news.adamastor.ac.za>...
> Hi there
>
> I've been trying to create a dynamic image using a servlet.I found some code
> on the Net to help me out, but I'm struggling to understand all the code.All
> its suppose to do is create a simple jpeg image containing a few words and
> write it to the screen.
>
> Can anybody help me out? The url I found the code on is
> http://www.drbob42.com/jbuilder/img_srvl.htm
>
> Any help would be very much appreciated
>
> Regards
> LeRoux
Technical Details
Message-ID:
<cc57715e.0106051254.605ab401@posting.google.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!postnews1.google.com!not-for-mailReferences:
<9ffjil$2k3c$1@news.adamastor.ac.za>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5d71,8c58e4717c1a176c X-Google-Attributes: gidf5d71,public X-Google-Thread: f74b3,8c58e4717c1a176c X-Google-Attributes: gidf74b3,public X-Google-Thread: f47f5,8c58e4717c1a176c X-Google-Attributes: gidf47f5,public X-Google-Thread: 113ae9,8c58e4717c1a176c X-Google-Attributes: gid113ae9,public X-Google-ArrivalTime: 2001-06-05 13:54:39 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!postnews1.google.com!not-for-mail From: ravirajbhide@yahoo.com (Ravi) Newsgroups: borland.public.jbuilder.java.language,comp.lang.java,comp.lang.java.3d,comp.lang.java.help Subject: Re: Dynamic Images in Servlets Date: 5 Jun 2001 13:54:38 -0700 Organization: http://groups.google.com/ Lines: 32 Message-ID: <cc57715e.0106051254.605ab401@posting.google.com> References: <9ffjil$2k3c$1@news.adamastor.ac.za> NNTP-Posting-Host: 64.160.169.5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 991774479 8886 127.0.0.1 (5 Jun 2001 20:54:39 GMT) X-Complaints-To: groups-support@google.com NNTP-Posting-Date: 5 Jun 2001 20:54:39 GMT