use of org.jwildfire.swing.ImageFileChooser in project JWildfire by thargor6.
the class TinaController method selectImageForGradientButton_actionPerformed.
public void selectImageForGradientButton_actionPerformed(ActionEvent e) {
JFileChooser chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
if (prefs.getInputImagePath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getInputImagePath()));
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (chooser.showOpenDialog(centerPanel) == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
try {
String filename = file.getAbsolutePath();
WFImage img = RessourceManager.getImage(filename);
if (img.getImageWidth() < 16 || img.getImageHeight() < 16 || !(img instanceof SimpleImage)) {
throw new Exception("Invalid gradient map");
}
prefs.setLastInputImageFile(file);
saveUndoPoint();
getCurrLayer().setGradientMapFilename(filename);
setLastGradient(getCurrLayer().getPalette());
refreshPaletteColorsTable();
refreshPaletteUI(getCurrLayer().getPalette());
refreshFlameImage(true, false, 1, true, false);
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
}
use of org.jwildfire.swing.ImageFileChooser in project JWildfire by thargor6.
the class TinaInteractiveRendererController method saveImageButton_clicked.
public void saveImageButton_clicked() {
try {
pauseRenderThreads();
try {
JFileChooser chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
if (prefs.getOutputImagePath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getOutputImagePath()));
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (chooser.showSaveDialog(imageRootPanel) == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
prefs.setLastOutputImageFile(file);
RenderedFlame res = renderer.finishRenderFlame(displayUpdater.getSampleCount());
new ImageWriter().saveImage(res.getImage(), file.getAbsolutePath());
if (res.getHDRImage() != null) {
new ImageWriter().saveImage(res.getHDRImage(), Tools.makeHDRFilename(file.getAbsolutePath()));
}
if (res.getZBuffer() != null) {
new ImageWriter().saveImage(res.getZBuffer(), Tools.makeZBufferFilename(file.getAbsolutePath()));
}
if (prefs.isTinaSaveFlamesWhenImageIsSaved()) {
new FlameWriter().writeFlame(getCurrFlame(), file.getParentFile().getAbsolutePath() + File.separator + Tools.trimFileExt(file.getName()) + ".flame");
}
if (autoLoadImageCBx.isSelected()) {
parentCtrl.mainController.loadImage(file.getAbsolutePath(), false);
}
}
} finally {
resumeRenderThreads();
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
Aggregations