public void boardSaveImage() {
if (curfileImage == null) {
boardSaveAsImage();
return;
}
final Dialog waitD = new Dialog(this.frame, Messages
.getString("BoardEditor.waitDialog.title")); //$NON-NLS-1$
waitD.add(new Label(Messages
.getString("BoardEditor.waitDialog.message"))); //$NON-NLS-1$
waitD.setSize(250, 130);
// move to middle of screen
waitD.setLocation(
frame.getSize().width / 2 - waitD.getSize().width / 2, frame
.getSize().height
/ 2 - waitD.getSize().height / 2);
waitD.setVisible(true);
frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
waitD.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
// save!
final int filter = 0; // 0 - no filter; 1 - sub; 2 - up
final int compressionLevel = 9; // 0 to 9 with 0 being no compression
final PngEncoder png = new PngEncoder(bv.getEntireBoardImage(),
PngEncoder.NO_ALPHA, filter, compressionLevel);
try {
final FileOutputStream outfile = new FileOutputStream(curfileImage);
byte[] pngbytes;
pngbytes = png.pngEncode();
if (pngbytes == null) {
System.out.println("Failed to save board as image:Null image"); //$NON-NLS-1$
} else {
outfile.write(pngbytes);
}
outfile.flush();
outfile.close();
} catch (final IOException e) {
e.printStackTrace();
}
waitD.setVisible(false);
frame.setCursor(Cursor.getDefaultCursor());
}