Search in sources :

Example 11 with WFImage

use of org.jwildfire.image.WFImage 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)

Aggregations

WFImage (org.jwildfire.image.WFImage)11 SimpleImage (org.jwildfire.image.SimpleImage)9 File (java.io.File)8 JFileChooser (javax.swing.JFileChooser)4 JLabel (javax.swing.JLabel)4 ImageReader (org.jwildfire.io.ImageReader)4 ImageFileChooser (org.jwildfire.swing.ImageFileChooser)4 MaterialSettings (org.jwildfire.create.tina.base.solidrender.MaterialSettings)2 MedianCutQuantizer (org.jwildfire.create.tina.palette.MedianCutQuantizer)2 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)2 Color (java.awt.Color)1 FileNotFoundException (java.io.FileNotFoundException)1 Stereo3dColor (org.jwildfire.create.tina.base.Stereo3dColor)1 RGBColor (org.jwildfire.create.tina.palette.RGBColor)1 ThumbnailCacheKey (org.jwildfire.create.tina.swing.ThumbnailCacheKey)1 SimpleHDRImage (org.jwildfire.image.SimpleHDRImage)1