|
|
Re: Save text file with images
|
Posted: Sep 19, 2005 3:52 AM
|
|
> Could someone, gives to me a example of this > problems, please, I've been trying Filewriter, ImageIO, > etc.
/* When you call this method: "someMethod" you should pass
* in a JPanel that has the pic that you want.
*/
public void someMethod(Component component){
File file = new File("saveToThisFile.jpg");
BufferedImage image = generatedBufferedImage(component);
ImageIO.write(image, "jpg", file);
}
public BufferedImage generatedBufferedImage(Component component){
BufferedImage image = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.fillRect(0, 0, image.getWidth(), image.getHeight());
component.print(g);
g.dispose();
return image;
}
Good luck...
|
|