aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Generating images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Generating images" Watch "Generating images" New topic
Author

Generating images

pradeep selvaraj
Ranch Hand

Joined: Nov 29, 2005
Posts: 62
How could i generate images in memory and save them into a image(any image format) file.

Thanks


[<a href="http://cyvis.sourceforge.net" target="_blank" rel="nofollow">CyVis - Software Complexity Visualiser</a>] [<a href="http://pradeepselvaraj.blogspot.com" target="_blank" rel="nofollow">Pradeep's Blog</a>]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

The easiest way to do this is use the new ImageIO API - the last sample on this page shows how easy it is to read and write images in many formats using it. The only problem is that ImageIO does not support writing GIF files "out of the box" currently - however, there are plugins you can use to do so, and GIF encoding will be included in the next JDK release (since the GIF patent will have expired).

The "in memory" part would be accomplished by using the BufferedImage class. You create one (or load one using ImageIO), call getGraphics() or createGraphics() on it to get the graphics context, and then just draw on it the same way you would draw on an AWT component in it's paint() method or a Swing component in it's paintComponent() method.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generating images
 
Similar Threads
FireFox 2.0 not picking background in CSS
images
lucene and image search
what was your favorite toy when you were a kid?
image in netbeans