Bufferedimages directly to zip file in Java
How can I save lots of Bufferedimages directly to zip file? BufferedImages
array to zip file maybe? Just not to disk it is slow!
public static void main(String[] args) throws Exception {
for (int i = 0; i < 10; i++) {
JFrame jf = new JFrame();
Panel a = new Panel();
JRadioButton birdButton = new JRadioButton();
birdButton.setSize(100, 100);
birdButton.setSelected(true);
jf.add(birdButton);
getSaveSnapShot(birdButton, i + ".bmp");
}
}
public static BufferedImage getScreenShot(Component component) {
BufferedImage image = new BufferedImage(component.getWidth(),
component.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
// paints into image's Graphics
component.paint(image.getGraphics());
return image;
}
public static void getSaveSnapShot(Component component, String
fileName) throws Exception {
BufferedImage img = getScreenShot(component);
// BufferedImage img = new
BufferedImage(image.getWidth(),image.getHeight(),BufferedImage.TYPE_BYTE_GRAY);
// write the captured image as a bmp
ImageIO.write(img, "bmp", new File(fileName));
}
No comments:
Post a Comment