Re: creating buffered image
In article
<db5ceda2-5915-469c-9f06-76b4af303abc@35g2000prt.googlegroups.com>,
mark jason <markjason72@gmail.com> wrote:
On Nov 12, 4:41??pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
[...]
I'd probably just use a BufferedImage; that way I can use ImageIO,
as suggested in the tutorial:
Thanks for the help. That makes things a lot easier.
That's been my experience, too; but, should the need arise, you can
also use a BufferedImage to render and save an Image from another
source, such as the gradient seen in the MemoryImageSource API:
<http://download.oracle.com/javase/6/docs/api/java/awt/image/MemoryImageSource.html>
private void save(Image image) {
int w = image.getWidth(null);
int h = image.getHeight(null);
BufferedImage bi = new BufferedImage(
w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bi.createGraphics();
g2d.drawImage(image, 0, 0, null);
try {
ImageIO.write(bi, "JPEG", new File("new.jpg"));
} catch (IOException ex) {
ex.printStackTrace(System.err);
}
g2d.dispose();
}
I was curious to see what it looked like:
<http://tinypic.com/r/2qk03zq/7>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>