A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Java in General
Author
Saving an ImageIcon to a file
Barry Brashear
Ranch Hand
Joined: Jun 05, 2001
Posts: 303
posted
Jun 21, 2005 13:39:00
0
How do I save an image icon in a file. It also has to be in a format that
a web page would be able to display.
Thanks.
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8259
I like...
posted
Jun 21, 2005 14:45:00
0
ImageIcon
has a getImage() method.
javax.imageio.ImageIO
can write
RenderedImage
instances to file. How do you convert between an Image and
RenderedImage
instance?
public static BufferedImage toBufferedImage(Image img){ int width = img.getWidth(null); int height = img.getHeight(null); BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics g = bi.getGraphics(); g.drawImage(img, 0,0, null); g.dispose(); return bi; }
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[
How To Ask Questions On JavaRanch
]
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: Saving an ImageIcon to a file
Similar Threads
Creating a file by giving relative path
WA #1.....word association
java io
Struts FormFile (parsing .csv files)
performance issues with file read and write
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter