File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using graphics in servlets

 
mateen dar
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i am ceating a web application that must open a picture and then draw on it. i have done it in desktop applications, but now want to use in a servlet. can i use the graphics2d library from within a servlet and how would u translate the following code,


try
{
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(img, 0);
tracker.waitForID(0);
}


the img is a fle read from the hadrd drive. and the this referebce is the reference for a jframe class. how can i use the above code in a servlet. thanks.
 
mateen dar
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think i did not make my self clear in the above post. i want toread a image file, into a buffered image. how could i do that.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just went through exactly this problem - my previous graphics work was in Applets and used MediaTracker but it turns out the situation has greatly improved since then. Now I am using the ImageIO class - which does not start a separate Thread.

where theImage is a BufferedImage reference.

And to draw on that image, you do a typical


To cope with various image formats, the JAI package found here seems to be where the future support is.
Bill
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on the OS you're using, you may need to run your app server with the "headless" JVM option.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic