Search in sources :

Example 11 with ImageWriter

use of org.jwildfire.io.ImageWriter 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);
    }
}
Also used : FlameWriter(org.jwildfire.create.tina.io.FlameWriter) JFileChooser(javax.swing.JFileChooser) ImageFileChooser(org.jwildfire.swing.ImageFileChooser) ImageWriter(org.jwildfire.io.ImageWriter) File(java.io.File) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Aggregations

ImageWriter (org.jwildfire.io.ImageWriter)11 File (java.io.File)6 JFileChooser (javax.swing.JFileChooser)4 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)4 SimpleImage (org.jwildfire.image.SimpleImage)4 FlameWriter (org.jwildfire.create.tina.io.FlameWriter)3 ImageFileChooser (org.jwildfire.swing.ImageFileChooser)3 Flame (org.jwildfire.create.tina.base.Flame)2 FACLFlameWriter (org.jwildfire.create.tina.faclrender.FACLFlameWriter)2 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)2 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 PCPoint (org.jwildfire.create.tina.base.raster.RasterPointCloud.PCPoint)1 FACLRenderResult (org.jwildfire.create.tina.faclrender.FACLRenderResult)1 FlameReader (org.jwildfire.create.tina.io.FlameReader)1 SunFlowWriter (org.jwildfire.io.SunFlowWriter)1