Search in sources :

Example 21 with RenderedFlame

use of org.jwildfire.create.tina.render.RenderedFlame in project JWildfire by thargor6.

the class EnvelopeDialog method refreshFlameImage.

public void refreshFlameImage() {
    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 = getFlame();
        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.getPrefs(), false, false);
                renderer.setProgressUpdater(null);
                if (flame.getSolidRenderSettings().isSolidRenderingEnabled()) {
                    flame.setCamDOF(0.0);
                    flame.getSolidRenderSettings().setAoEnabled(false);
                    if (ShadowType.SMOOTH.equals(flame.getSolidRenderSettings().getShadowType())) {
                        flame.getSolidRenderSettings().setShadowType(ShadowType.FAST);
                    } else {
                        flame.getSolidRenderSettings().setShadowType(ShadowType.OFF);
                    }
                    flame.setSampleDensity(Prefs.getPrefs().getTinaRenderRealtimeQuality() * 2.0);
                } else {
                    flame.setSampleDensity(Prefs.getPrefs().getTinaRenderRealtimeQuality() * 6.0);
                }
                flame.setSpatialFilterRadius(0.0);
                RenderedFlame res = renderer.renderFlame(info);
                imgPanel.setImage(res.getImage());
            } finally {
                flame.setSpatialFilterRadius(oldSpatialFilterRadius);
                flame.setSampleDensity(oldSampleDensity);
            }
        }
    } else {
        imgPanel.setImage(new SimpleImage(width, height));
    }
    getPreviewRootPanel().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) Point(java.awt.Point) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 22 with RenderedFlame

use of org.jwildfire.create.tina.render.RenderedFlame in project JWildfire by thargor6.

the class JWFMovieFilePreview method createThumbnail.

public void createThumbnail() {
    if (currFile == null) {
        currThumbnail = null;
        return;
    }
    try {
        if (currFile.exists()) {
            FlameMovie movie = new FlameMovieReader(prefs).readMovie(currFile.getAbsolutePath());
            Flame flame = null;
            if (movie != null) {
                for (FlameMoviePart part : movie.getParts()) {
                    if (part.getFlame() != null) {
                        flame = part.getFlame();
                        break;
                    }
                }
            }
            if (flame != null) {
                int imgWidth = this.getPreferredSize().width;
                int imgHeight = this.getPreferredSize().height;
                double wScl = (double) imgWidth / (double) flame.getWidth();
                double hScl = (double) imgHeight / (double) flame.getHeight();
                flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
                flame.setWidth(imgWidth);
                flame.setHeight(imgHeight);
                FlameRenderer renderer = new FlameRenderer(flame, prefs, false, true);
                renderer.setProgressUpdater(null);
                flame.setSampleDensity(50);
                flame.setSpatialFilterRadius(0.0);
                RenderInfo info = new RenderInfo(imgWidth, imgHeight, RenderMode.PREVIEW);
                RenderedFlame res = renderer.renderFlame(info);
                currThumbnail = new ImageIcon(res.getImage().getBufferedImg());
            }
        }
    } catch (Exception ex) {
        currThumbnail = null;
        if (ex.getCause() != null) {
            ex.getCause().printStackTrace();
        } else {
            ex.printStackTrace();
        }
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) FlameMovieReader(org.jwildfire.create.tina.io.FlameMovieReader) FlameMovie(org.jwildfire.create.tina.animate.FlameMovie) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) FlameMoviePart(org.jwildfire.create.tina.animate.FlameMoviePart) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 23 with RenderedFlame

use of org.jwildfire.create.tina.render.RenderedFlame in project JWildfire by thargor6.

the class IFlamesController method refreshBaseFlamePreview.

private void refreshBaseFlamePreview() {
    FlamePanel imgPanel = getBaseFlamePreviewPanel();
    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 = getBaseFlame();
        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);
                renderer.setProgressUpdater(null);
                flame.setSampleDensity(1.0);
                flame.setSpatialFilterRadius(0.0);
                RenderedFlame res = renderer.renderFlame(info);
                imgPanel.setImage(res.getImage());
            } finally {
                flame.setSpatialFilterRadius(oldSpatialFilterRadius);
                flame.setSampleDensity(oldSampleDensity);
            }
        } else {
            imgPanel.setImage(new SimpleImage(width, height));
        }
    } else {
        imgPanel.setImage(new SimpleImage(width, height));
    }
    baseFlamePreviewRootPnl.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 24 with RenderedFlame

use of org.jwildfire.create.tina.render.RenderedFlame 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

RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)24 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)22 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)22 Flame (org.jwildfire.create.tina.base.Flame)18 SimpleImage (org.jwildfire.image.SimpleImage)11 Rectangle (java.awt.Rectangle)9 FlamePanel (org.jwildfire.create.tina.swing.flamepanel.FlamePanel)9 ImageWriter (org.jwildfire.io.ImageWriter)4 File (java.io.File)3 ImageIcon (javax.swing.ImageIcon)3 XYZProjectedPoint (org.jwildfire.create.tina.base.XYZProjectedPoint)3 FlameReader (org.jwildfire.create.tina.io.FlameReader)3 DrawFocusPointFlameRenderer (org.jwildfire.create.tina.render.DrawFocusPointFlameRenderer)3 FlamePanelConfig (org.jwildfire.create.tina.swing.flamepanel.FlamePanelConfig)3 JFileChooser (javax.swing.JFileChooser)2 Layer (org.jwildfire.create.tina.base.Layer)2 FlameWriter (org.jwildfire.create.tina.io.FlameWriter)2 ImageFileChooser (org.jwildfire.swing.ImageFileChooser)2 TextTransformer (org.jwildfire.transform.TextTransformer)2 Color (java.awt.Color)1