Search in sources :

Example 46 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class TinaController method selectImageForBackgroundButton_actionPerformed.

public void selectImageForBackgroundButton_actionPerformed(ActionEvent e) {
    JFileChooser chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
    if (prefs.getInputImagePath() != null) {
        try {
            if (getCurrFlame().getBGImageFilename().length() > 0) {
                chooser.setSelectedFile(new File(getCurrFlame().getBGImageFilename()));
            } else {
                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() < 2 || img.getImageHeight() < 2 || !(img instanceof SimpleImage)) {
                throw new Exception("Invalid background image");
            }
            prefs.setLastInputImageFile(file);
            saveUndoPoint();
            getCurrFlame().setBGImageFilename(filename);
            refreshFlameImage(true, false, 1, true, true);
        } 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 47 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class MapFilePreview method createThumbnail.

public void createThumbnail() {
    if (currFile == null) {
        currThumbnail = null;
        return;
    }
    try {
        if (currFile.exists()) {
            List<RGBPalette> gradients = new MapGradientReader().readPalettes(currFile.getAbsolutePath());
            int imgWidth = this.getPreferredSize().width;
            int imgHeight = this.getPreferredSize().height - BUTTON_HEIGHT;
            SimpleImage img = new RGBPaletteRenderer().renderHorizPalette(gradients.get(0), imgWidth, imgHeight);
            currThumbnail = new ImageIcon(img.getBufferedImg());
        }
    } catch (Exception ex) {
        currThumbnail = null;
        if (ex.getCause() != null) {
            ex.getCause().printStackTrace();
        } else {
            ex.printStackTrace();
        }
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) MapGradientReader(org.jwildfire.create.tina.io.MapGradientReader) RGBPalette(org.jwildfire.create.tina.palette.RGBPalette) SimpleImage(org.jwildfire.image.SimpleImage) RGBPaletteRenderer(org.jwildfire.create.tina.palette.RGBPaletteRenderer)

Example 48 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class TinaSWFAnimatorController method createRandomBatch.

public boolean createRandomBatch(int pCount, String pGeneratorname) {
    if (prefs.getTinaRandomBatchRefreshType() == RandomBatchRefreshType.CLEAR) {
        randomBatch.clear();
    }
    int imgCount = prefs.getTinaRandomMovieBatchSize();
    List<SimpleImage> imgList = new ArrayList<SimpleImage>();
    int maxCount = (pCount > 0 ? pCount : imgCount);
    renderProgressUpdater.initProgress(maxCount);
    RandomMovieGenerator randGen = RandomMovieGeneratorList.getRandomMovieGeneratorInstance(pGeneratorname, true);
    for (int i = 0; i < maxCount; i++) {
        MovieThumbnail thumbnail;
        thumbnail = new MovieThumbnail(randGen.createMovie(prefs), null);
        SimpleImage img = thumbnail.getPreview(3 * prefs.getTinaRenderPreviewQuality() / 4);
        if (prefs.getTinaRandomBatchRefreshType() == RandomBatchRefreshType.INSERT) {
            randomBatch.add(0, thumbnail);
            imgList.add(0, img);
        } else {
            randomBatch.add(thumbnail);
            imgList.add(img);
        }
        renderProgressUpdater.updateProgress(i + 1);
    }
    updateThumbnails();
    return true;
}
Also used : RandomMovieGenerator(org.jwildfire.create.tina.randommovie.RandomMovieGenerator) SimpleImage(org.jwildfire.image.SimpleImage) ArrayList(java.util.ArrayList)

Example 49 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class TinaSWFAnimatorController method refreshFlameImage.

public void refreshFlameImage(boolean pQuickRender) {
    if (!noRefresh) {
        FlamePanel imgPanel = getFlamePanel();
        Rectangle bounds = imgPanel.getImageBounds();
        int width = bounds.width;
        int height = bounds.height;
        if (width >= 16 && height >= 16) {
            RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
            Flame flame = getCurrFlame();
            if (flame != null) {
                double oldSpatialFilterRadius = flame.getSpatialFilterRadius();
                double oldSampleDensity = flame.getSampleDensity();
                try {
                    double wScl = (double) info.getImageWidth() / (double) flame.getWidth();
                    double hScl = (double) info.getImageHeight() / (double) flame.getHeight();
                    flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
                    flame.setWidth(info.getImageWidth());
                    flame.setHeight(info.getImageHeight());
                    FlameRenderer renderer = new FlameRenderer(flame, prefs, false, false);
                    if (pQuickRender) {
                        renderer.setProgressUpdater(null);
                        flame.setSampleDensity(1.0);
                        flame.setSpatialFilterRadius(0.0);
                    } else {
                        renderer.setProgressUpdater(renderProgressUpdater);
                        flame.setSampleDensity(prefs.getTinaRenderPreviewQuality());
                    }
                    RenderedFlame res = renderer.renderFlame(info);
                    imgPanel.setImage(res.getImage());
                } finally {
                    flame.setSpatialFilterRadius(oldSpatialFilterRadius);
                    flame.setSampleDensity(oldSampleDensity);
                }
            }
        } else {
            imgPanel.setImage(new SimpleImage(width, height));
        }
        swfAnimatorPreviewRootPanel.repaint();
    }
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) Rectangle(java.awt.Rectangle) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 50 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class FlamePanel method fillBackground.

private void fillBackground(Graphics g) {
    Rectangle bounds = this.getBounds();
    if (withShowTransparency) {
        SimpleImage bgImg = getTransparencyImg(bounds.width, bounds.height);
        g.drawImage(bgImg.getBufferedImg(), 0, 0, bounds.width, bounds.height, this);
    } else {
        g.setColor(BACKGROUND_COLOR);
        g.fillRect(0, 0, bounds.width, bounds.height);
    }
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) Rectangle(java.awt.Rectangle)

Aggregations

SimpleImage (org.jwildfire.image.SimpleImage)174 Pixel (org.jwildfire.image.Pixel)37 ImagePanel (org.jwildfire.swing.ImagePanel)24 FlamePanel (org.jwildfire.create.tina.swing.flamepanel.FlamePanel)20 Dimension (java.awt.Dimension)18 Flame (org.jwildfire.create.tina.base.Flame)17 File (java.io.File)16 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)16 ArrayList (java.util.ArrayList)14 Rectangle (java.awt.Rectangle)12 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)12 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)12 Graphics (java.awt.Graphics)10 SimpleHDRImage (org.jwildfire.image.SimpleHDRImage)10 WFImage (org.jwildfire.image.WFImage)9 ImageReader (org.jwildfire.io.ImageReader)9 JPanel (javax.swing.JPanel)8 JScrollPane (javax.swing.JScrollPane)8 ResolutionProfile (org.jwildfire.base.ResolutionProfile)8 Color (java.awt.Color)7