Search in sources :

Example 16 with RenderedFlame

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

the class MeshGenController method refreshFlameImage.

public void refreshFlameImage(boolean pQuickRender, JPanel pRootPanel, FlameHolder pFlameHolder) {
    if (!refreshing) {
        FlamePanel imgPanel = getFlamePanel(pRootPanel, pFlameHolder);
        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 = pFlameHolder.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, false, false);
                    if (pQuickRender) {
                        renderer.setProgressUpdater(null);
                        flame.setSampleDensity(3.0);
                        flame.setSpatialFilterRadius(0.0);
                    } else {
                        renderer.setProgressUpdater(renderSequenceProgressUpdater);
                        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));
        }
        pRootPanel.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 17 with RenderedFlame

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

the class DancingFractalsController method refreshFlameImage.

public void refreshFlameImage(Flame flame, boolean pDrawTriangles, double pFPS, long pFrame, boolean pDrawFPS) {
    FlamePanel imgPanel = getFlamePanel();
    if (imgPanel == null)
        return;
    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);
        if (flame != null) {
            double oldSpatialFilterRadius = flame.getSpatialFilterRadius();
            double oldSampleDensity = flame.getSampleDensity();
            imgPanel.setDrawTriangles(pDrawTriangles);
            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());
                Flame renderFlame = new FlamePreparer(prefs).createRenderFlame(flame);
                FlameRenderer renderer = new FlameRenderer(renderFlame, prefs, false, false);
                renderer.setProgressUpdater(null);
                RenderedFlame res = renderer.renderFlame(info);
                SimpleImage img = res.getImage();
                if (pDrawFPS) {
                    TextTransformer txt = new TextTransformer();
                    txt.setText1("fps: " + Tools.doubleToString(pFPS) + ", time: " + Tools.doubleToString(pFrame / 1000.0) + "s");
                    txt.setAntialiasing(false);
                    txt.setColor(Color.LIGHT_GRAY);
                    txt.setMode(Mode.NORMAL);
                    txt.setFontStyle(FontStyle.PLAIN);
                    txt.setFontName("Arial");
                    txt.setFontSize(10);
                    txt.setHAlign(HAlignment.LEFT);
                    txt.setVAlign(VAlignment.BOTTOM);
                    txt.transformImage(img);
                }
                imgPanel.setImage(img);
            } finally {
                flame.setSpatialFilterRadius(oldSpatialFilterRadius);
                flame.setSampleDensity(oldSampleDensity);
            }
        }
    } else {
        try {
            imgPanel.setImage(new SimpleImage(width, height));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    flameRootPanel.repaint();
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) Rectangle(java.awt.Rectangle) TextTransformer(org.jwildfire.transform.TextTransformer) 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 18 with RenderedFlame

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

the class DancingFractalsController method refreshPoolPreviewFlameImage.

public void refreshPoolPreviewFlameImage(Flame flame) {
    FlamePanel imgPanel = getPoolPreviewFlamePanel();
    if (imgPanel == null)
        return;
    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);
        if (flame != null) {
            imgPanel.setDrawTriangles(false);
            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());
            Flame renderFlame = new FlamePreparer(prefs).createRenderFlame(flame);
            FlameRenderer renderer = new FlameRenderer(renderFlame, prefs, false, false);
            renderer.setProgressUpdater(null);
            RenderedFlame res = renderer.renderFlame(info);
            imgPanel.setImage(res.getImage());
        } else {
            imgPanel.setImage(new SimpleImage(width, height));
        }
    } else {
        imgPanel.setImage(new SimpleImage(width, height));
    }
    poolFlamePreviewPnl.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 19 with RenderedFlame

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

the class CacheRendererThread method renderFlame.

private SimpleImage renderFlame(FlameFlatNode pNode, int pImgWidth, int pImgHeight) {
    List<Flame> flames = new FlameReader(prefs).readFlames(pNode.getFilename());
    if (flames.size() > 0) {
        Flame renderFlame = flames.get(0);
        RenderInfo info = new RenderInfo(pImgWidth, pImgHeight, RenderMode.PREVIEW);
        double wScl = (double) info.getImageWidth() / (double) renderFlame.getWidth();
        double hScl = (double) info.getImageHeight() / (double) renderFlame.getHeight();
        renderFlame.setPixelsPerUnit((wScl + hScl) * 0.5 * renderFlame.getPixelsPerUnit());
        renderFlame.setWidth(pImgWidth);
        renderFlame.setHeight(pImgHeight);
        renderFlame.setSampleDensity(prefs.getTinaRenderPreviewQuality() / 3.0);
        FlameRenderer renderer = new FlameRenderer(renderFlame, prefs, false, true);
        RenderedFlame renderRes = renderer.renderFlame(info);
        return renderRes.getImage();
    }
    return null;
}
Also used : FlameReader(org.jwildfire.create.tina.io.FlameReader) 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 20 with RenderedFlame

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

the class FlameThumbnail method generatePreview.

private void generatePreview(int pQuality) {
    if (cacheKey != null) {
        preview = ThumbnailCacheProvider.getThumbnail(cacheKey, IMG_WIDTH, IMG_HEIGHT, pQuality);
        if (preview != null) {
            return;
        }
    }
    Prefs prefs = Prefs.getPrefs();
    RenderInfo info = new RenderInfo(IMG_WIDTH, IMG_HEIGHT, RenderMode.PREVIEW);
    Flame renderFlame = flame.makeCopy();
    double wScl = (double) info.getImageWidth() / (double) renderFlame.getWidth();
    double hScl = (double) info.getImageHeight() / (double) renderFlame.getHeight();
    renderFlame.setPixelsPerUnit((wScl + hScl) * 0.5 * renderFlame.getPixelsPerUnit());
    renderFlame.setWidth(IMG_WIDTH);
    renderFlame.setHeight(IMG_HEIGHT);
    renderFlame.setSampleDensity(prefs.getTinaRenderPreviewQuality());
    renderFlame.setSpatialFilterRadius(0.0);
    FlameRenderer renderer = new FlameRenderer(renderFlame, prefs, false, false);
    renderFlame.setSampleDensity(pQuality);
    RenderedFlame res = renderer.renderFlame(info);
    preview = res.getImage();
    if (cacheKey != null) {
        ThumbnailCacheProvider.storeThumbnail(cacheKey, IMG_WIDTH, IMG_HEIGHT, pQuality, preview);
    }
}
Also used : FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) Prefs(org.jwildfire.base.Prefs) 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)

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