Search in sources :

Example 21 with RenderInfo

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

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

the class FlamePreviewHelper method startBackgroundRender.

private void startBackgroundRender(FlamePanel pImgPanel) {
    prevRaster = null;
    if (flameHolder == null) {
        return;
    }
    Flame flame = flameHolder.getFlame().makeCopy();
    flame.applyFastOversamplingSettings();
    Rectangle panelBounds = pImgPanel.getParentImageBounds();
    RenderInfo info = new RenderInfo(panelBounds.width, panelBounds.height, RenderMode.PREVIEW);
    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.setSampleDensity(10.0);
    info.setRenderHDR(false);
    info.setRenderZBuffer(false);
    renderer = new FlameRenderer(flame, prefs, flame.isBGTransparency(), false);
    renderer.registerIterationObserver(this);
    SimpleImage image = new SimpleImage(pImgPanel.getImage().getImageWidth(), pImgPanel.getImage().getImageHeight());
    initImage(image, flame);
    displayUpdater = new BufferedInteractiveRendererDisplayUpdater(pImgPanel, image, true);
    displayUpdater.initRender(prefs.getTinaRenderThreads());
    threads = renderer.startRenderFlame(info);
    for (Thread thread : threads.getExecutingThreads()) {
        thread.setPriority(Thread.MIN_PRIORITY);
    }
    updateDisplayThread = new UpdateDisplayThread(flame, image);
    updateDisplayExecuteThread = new Thread(updateDisplayThread);
    updateDisplayExecuteThread.setPriority(Thread.MIN_PRIORITY);
    updateDisplayExecuteThread.start();
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) Rectangle(java.awt.Rectangle) DrawFocusPointFlameRenderer(org.jwildfire.create.tina.render.DrawFocusPointFlameRenderer) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) AbstractRenderThread(org.jwildfire.create.tina.render.AbstractRenderThread)

Example 23 with RenderInfo

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

Example 24 with RenderInfo

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

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

Aggregations

FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)28 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)28 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)24 Flame (org.jwildfire.create.tina.base.Flame)21 SimpleImage (org.jwildfire.image.SimpleImage)12 Rectangle (java.awt.Rectangle)10 FlamePanel (org.jwildfire.create.tina.swing.flamepanel.FlamePanel)9 XYZProjectedPoint (org.jwildfire.create.tina.base.XYZProjectedPoint)4 DrawFocusPointFlameRenderer (org.jwildfire.create.tina.render.DrawFocusPointFlameRenderer)4 ImageIcon (javax.swing.ImageIcon)3 FlameReader (org.jwildfire.create.tina.io.FlameReader)3 AbstractRenderThread (org.jwildfire.create.tina.render.AbstractRenderThread)3 FlamePanelConfig (org.jwildfire.create.tina.swing.flamepanel.FlamePanelConfig)3 Layer (org.jwildfire.create.tina.base.Layer)2 FlameBGColorHandler (org.jwildfire.create.tina.render.FlameBGColorHandler)2 ImageWriter (org.jwildfire.io.ImageWriter)2 TextTransformer (org.jwildfire.transform.TextTransformer)2 Color (java.awt.Color)1 Point (java.awt.Point)1 File (java.io.File)1