Search in sources :

Example 1 with SunFlowWriter

use of org.jwildfire.io.SunFlowWriter in project JWildfire by thargor6.

the class MainController method saveImage.

public void saveImage() throws Exception {
    Buffer buffer = getActiveBuffer();
    if (buffer != null) {
        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(windowMenu) == JFileChooser.APPROVE_OPTION) {
            File file = chooser.getSelectedFile();
            prefs.setLastOutputImageFile(file);
            if (buffer.getBufferType() == BufferType.IMAGE) {
                new ImageWriter().saveImage(buffer.getImage(), file.getAbsolutePath());
            } else if (buffer.getBufferType() == BufferType.HDR_IMAGE) {
                new ImageWriter().saveImage(buffer.getHDRImage(), file.getAbsolutePath());
            } else if (buffer.getBufferType() == BufferType.MESH3D) {
                new SunFlowWriter().saveMesh(buffer.getMesh3D(), file.getAbsolutePath());
            } else {
                showMessage("Not supported");
                return;
            }
        }
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) SunFlowWriter(org.jwildfire.io.SunFlowWriter) ImageWriter(org.jwildfire.io.ImageWriter) File(java.io.File)

Aggregations

File (java.io.File)1 JFileChooser (javax.swing.JFileChooser)1 ImageWriter (org.jwildfire.io.ImageWriter)1 SunFlowWriter (org.jwildfire.io.SunFlowWriter)1