Search in sources :

Example 11 with ImageFileChooser

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);
        }
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) WFImage(org.jwildfire.image.WFImage) ImageFileChooser(org.jwildfire.swing.ImageFileChooser) SimpleImage(org.jwildfire.image.SimpleImage) File(java.io.File)

Example 12 with ImageFileChooser

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);
    }
}
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

File (java.io.File)12 JFileChooser (javax.swing.JFileChooser)12 ImageFileChooser (org.jwildfire.swing.ImageFileChooser)12 SimpleImage (org.jwildfire.image.SimpleImage)5 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)4 WFImage (org.jwildfire.image.WFImage)4 ImageWriter (org.jwildfire.io.ImageWriter)3 Flame (org.jwildfire.create.tina.base.Flame)2 FlameWriter (org.jwildfire.create.tina.io.FlameWriter)2 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)2 Font (java.awt.Font)1 QualityProfile (org.jwildfire.base.QualityProfile)1 ResolutionProfile (org.jwildfire.base.ResolutionProfile)1 XForm (org.jwildfire.create.tina.base.XForm)1 MaterialSettings (org.jwildfire.create.tina.base.solidrender.MaterialSettings)1 FACLFlameWriter (org.jwildfire.create.tina.faclrender.FACLFlameWriter)1 MeshGenRenderThread (org.jwildfire.create.tina.meshgen.render.MeshGenRenderThread)1 RenderPointCloudThread (org.jwildfire.create.tina.meshgen.render.RenderPointCloudThread)1 RenderSlicesThread (org.jwildfire.create.tina.meshgen.render.RenderSlicesThread)1 MedianCutQuantizer (org.jwildfire.create.tina.palette.MedianCutQuantizer)1