Z
ZelluX
Hi, all
I want to save the image on a JPanel to a JPG file, here is my code
ImageWriter iw = ImageIO.getImageWritersByFormatName("jpg").next();
BufferedImage bi = new BufferedImage(panel.getWidth(),
panel.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics g = bi.getGraphics();
panel.paintComponent(g);
ImageOutputStream ios = ImageIO.createImageOutputStream(new
FileOutputStream(path));
iw.setOutput(ios);
iw.write(bi);
g.dispose();
iw.dispose();
ios.close();
After this snippet of code finished, I clicked the created .jpg file,
but it showed nothing. After several seconds, I clicked again, and
this time the image turned up.
Can I diminish such delay?
Many thanks and sorry for my poor English
I want to save the image on a JPanel to a JPG file, here is my code
ImageWriter iw = ImageIO.getImageWritersByFormatName("jpg").next();
BufferedImage bi = new BufferedImage(panel.getWidth(),
panel.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics g = bi.getGraphics();
panel.paintComponent(g);
ImageOutputStream ios = ImageIO.createImageOutputStream(new
FileOutputStream(path));
iw.setOutput(ios);
iw.write(bi);
g.dispose();
iw.dispose();
ios.close();
After this snippet of code finished, I clicked the created .jpg file,
but it showed nothing. After several seconds, I clicked again, and
this time the image turned up.
Can I diminish such delay?
Many thanks and sorry for my poor English