Search in sources :

Example 6 with FlamePanel

use of org.jwildfire.create.tina.swing.flamepanel.FlamePanel in project JWildfire by thargor6.

the class BatchRendererController method renderBatchJobsTableClicked.

public void renderBatchJobsTableClicked() {
    FlamePanel imgPanel = getBatchPreviewFlamePanel();
    Rectangle bounds = imgPanel.getImageBounds();
    int width = bounds.width;
    int height = bounds.height;
    Flame flame = getBatchRenderPreviewFlameHolder().getFlame();
    if (width >= 16 && height >= 16) {
        RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
        if (flame != null) {
            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, data.toggleTransparencyButton.isSelected(), false);
            flame.setSampleDensity(prefs.getTinaRenderRealtimeQuality());
            flame.setSpatialFilterRadius(0.0);
            RenderedFlame res = renderer.renderFlame(info);
            imgPanel.setImage(res.getImage());
        } else {
            imgPanel.setImage(new SimpleImage(width, height));
        }
    }
    data.batchPreviewRootPanel.invalidate();
    data.batchPreviewRootPanel.validate();
}
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 7 with FlamePanel

use of org.jwildfire.create.tina.swing.flamepanel.FlamePanel in project JWildfire by thargor6.

the class EnvelopeDialog method getFlamePanel.

private FlamePanel getFlamePanel() {
    if (flamePanel == null) {
        int width = getPreviewRootPanel().getWidth();
        int height = getPreviewRootPanel().getHeight();
        SimpleImage img = new SimpleImage(width, height);
        img.fillBackground(0, 0, 0);
        flamePanel = new FlamePanel(Prefs.getPrefs(), img, 0, 0, getPreviewRootPanel().getWidth(), this, null);
        flamePanel.setRenderWidth(800);
        flamePanel.setRenderHeight(600);
        flamePanel.setFocusable(true);
        getPreviewRootPanel().add(flamePanel, BorderLayout.CENTER);
    // getPreviewRootPanel().getParent().validate();
    // getPreviewRootPanel().repaint();
    // flamePanel.requestFocusInWindow();
    }
    return flamePanel;
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel) Point(java.awt.Point)

Example 8 with FlamePanel

use of org.jwildfire.create.tina.swing.flamepanel.FlamePanel in project JWildfire by thargor6.

the class FlamePreviewHelper method fastRenderFlameImage.

public SimpleImage fastRenderFlameImage(boolean pQuickRender, boolean pMouseDown, int pDownScale) {
    FlamePanel imgPanel = flamePanelProvider.getFlamePanel();
    FlamePanelConfig cfg = flamePanelProvider.getFlamePanelConfig();
    Rectangle panelBounds = imgPanel.getParentImageBounds();
    Rectangle bounds;
    if (pDownScale != 1) {
        bounds = new Rectangle(panelBounds.width / pDownScale, panelBounds.height / pDownScale);
    } else {
        bounds = panelBounds;
    }
    int renderScale = pQuickRender && pMouseDown ? 2 : 1;
    int width = bounds.width / renderScale;
    int height = bounds.height / renderScale;
    if (width >= 16 && height >= 16) {
        RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
        Flame flame = flameHolder.getFlame();
        if (flame != null) {
            double oldSpatialFilterRadius = flame.getSpatialFilterRadius();
            double oldSampleDensity = flame.getSampleDensity();
            int oldSpatialOversampling = flame.getSpatialOversampling();
            boolean oldPostNoiseFilter = flame.isPostNoiseFilter();
            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());
                try {
                    FlameRenderer renderer;
                    if (isDrawFocusPointEnabled(cfg)) {
                        renderer = new DrawFocusPointFlameRenderer(flame, prefs, isTransparencyEnabled());
                    } else {
                        renderer = new FlameRenderer(flame, prefs, isTransparencyEnabled(), false);
                    }
                    renderer.setProgressUpdater(null);
                    flame.setSampleDensity(prefs.getTinaRenderRealtimeQuality());
                    flame.applyFastOversamplingSettings();
                    renderer.setRenderScale(renderScale);
                    RenderedFlame res = renderer.renderFlame(info);
                    SimpleImage img = res.getImage();
                    img.getBufferedImg().setAccelerationPriority(1.0f);
                    return img;
                } catch (Throwable ex) {
                    errorHandler.handleError(ex);
                }
            } finally {
                flame.setSampleDensity(oldSampleDensity);
                flame.setSpatialFilterRadius(oldSpatialFilterRadius);
                flame.setSpatialOversampling(oldSpatialOversampling);
                flame.setPostNoiseFilter(oldPostNoiseFilter);
            }
        }
    }
    return null;
}
Also used : Rectangle(java.awt.Rectangle) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel) DrawFocusPointFlameRenderer(org.jwildfire.create.tina.render.DrawFocusPointFlameRenderer) XYZProjectedPoint(org.jwildfire.create.tina.base.XYZProjectedPoint) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) SimpleImage(org.jwildfire.image.SimpleImage) DrawFocusPointFlameRenderer(org.jwildfire.create.tina.render.DrawFocusPointFlameRenderer) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) FlamePanelConfig(org.jwildfire.create.tina.swing.flamepanel.FlamePanelConfig) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 9 with FlamePanel

use of org.jwildfire.create.tina.swing.flamepanel.FlamePanel in project JWildfire by thargor6.

the class FlamePreviewHelper method renderFlameImage.

public SimpleImage renderFlameImage(boolean pQuickRender, boolean pMouseDown, int pDownScale, boolean pAllowUseCache) {
    if (!pAllowUseCache) {
        prevRaster = null;
    }
    FlamePanel imgPanel = flamePanelProvider.getFlamePanel();
    FlamePanelConfig cfg = flamePanelProvider.getFlamePanelConfig();
    Rectangle panelBounds = imgPanel.getParentImageBounds();
    Rectangle bounds;
    if (pDownScale != 1) {
        bounds = new Rectangle(panelBounds.width / pDownScale, panelBounds.height / pDownScale);
    } else {
        bounds = panelBounds;
    }
    int renderScale = pQuickRender && pMouseDown ? 2 : 1;
    int width = bounds.width / renderScale;
    int height = bounds.height / renderScale;
    if (width >= 16 && height >= 16) {
        RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
        Flame flame = flameHolder.getFlame();
        if (flame != null) {
            double oldSpatialFilterRadius = flame.getSpatialFilterRadius();
            double oldSampleDensity = flame.getSampleDensity();
            int oldSpatialOversampling = flame.getSpatialOversampling();
            boolean oldPostNoiseFilter = flame.isPostNoiseFilter();
            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());
                try {
                    FlameRenderer renderer;
                    if (pQuickRender) {
                        flame.setSampleDensity(prefs.getTinaRenderRealtimeQuality());
                        flame.applyFastOversamplingSettings();
                        flame.setSpatialOversampling(oldSpatialOversampling);
                    } else {
                        flame.setSampleDensity(prefs.getTinaRenderPreviewQuality());
                    }
                    if (isDrawFocusPointEnabled(cfg)) {
                        renderer = new DrawFocusPointFlameRenderer(flame, prefs, isTransparencyEnabled());
                    } else {
                        renderer = new FlameRenderer(flame, prefs, isTransparencyEnabled(), false);
                    }
                    if (pQuickRender) {
                        renderer.setProgressUpdater(null);
                    } else {
                        renderer.setProgressUpdater(mainProgressUpdater);
                    }
                    long t0 = System.currentTimeMillis();
                    renderer.setRenderScale(renderScale);
                    RenderedFlame res;
                    if (prevRaster != null && pAllowUseCache) {
                        info.setStoreRaster(false);
                        info.setRestoredRaster(prevRaster);
                        flame.setSampleDensity(prevRaster.getSampleDensity());
                        res = renderer.renderFlame(info);
                    } else {
                        info.setStoreRaster(true);
                        res = renderer.renderFlame(info);
                        prevRaster = res.getRaster();
                    }
                    SimpleImage img = res.getImage();
                    long t1 = System.currentTimeMillis();
                    img.getBufferedImg().setAccelerationPriority(1.0f);
                    if (layerAppendBtn != null && layerAppendBtn.isSelected() && !pMouseDown) {
                        showLayerAppendModeIndicator(img);
                    }
                    if (layerPreviewBtn != null && layerPreviewBtn.isSelected() && layerHolder != null) {
                        SimpleImage layerImg = createLayerPreview(img, renderScale, width, height);
                        showLayerPreview(img, layerImg, renderScale, width, height);
                    }
                    if (pDownScale != 1) {
                        SimpleImage background = new SimpleImage(panelBounds.width, panelBounds.height);
                        ComposeTransformer cT = new ComposeTransformer();
                        cT.setHAlign(ComposeTransformer.HAlignment.CENTRE);
                        cT.setVAlign(ComposeTransformer.VAlignment.CENTRE);
                        cT.setForegroundImage(img);
                        cT.transformImage(background);
                        img = background;
                    }
                    if (!cfg.isNoControls() && messageHelper != null) {
                        messageHelper.showStatusMessage(flame, "render time: " + Tools.doubleToString((t1 - t0) * 0.001) + "s");
                    }
                    return img;
                } catch (Throwable ex) {
                    errorHandler.handleError(ex);
                }
            } finally {
                flame.setSpatialFilterRadius(oldSpatialFilterRadius);
                flame.setSampleDensity(oldSampleDensity);
                flame.setSpatialOversampling(oldSpatialOversampling);
                flame.setPostNoiseFilter(oldPostNoiseFilter);
            }
        }
    }
    return null;
}
Also used : ComposeTransformer(org.jwildfire.transform.ComposeTransformer) Rectangle(java.awt.Rectangle) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel) DrawFocusPointFlameRenderer(org.jwildfire.create.tina.render.DrawFocusPointFlameRenderer) XYZProjectedPoint(org.jwildfire.create.tina.base.XYZProjectedPoint) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) SimpleImage(org.jwildfire.image.SimpleImage) DrawFocusPointFlameRenderer(org.jwildfire.create.tina.render.DrawFocusPointFlameRenderer) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) FlamePanelConfig(org.jwildfire.create.tina.swing.flamepanel.FlamePanelConfig) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 10 with FlamePanel

use of org.jwildfire.create.tina.swing.flamepanel.FlamePanel 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)

Aggregations

FlamePanel (org.jwildfire.create.tina.swing.flamepanel.FlamePanel)23 SimpleImage (org.jwildfire.image.SimpleImage)20 Rectangle (java.awt.Rectangle)9 Flame (org.jwildfire.create.tina.base.Flame)9 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)9 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)9 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)9 ResolutionProfile (org.jwildfire.base.ResolutionProfile)5 FlamePanelConfig (org.jwildfire.create.tina.swing.flamepanel.FlamePanelConfig)3 Point (java.awt.Point)2 XYZProjectedPoint (org.jwildfire.create.tina.base.XYZProjectedPoint)2 DrawFocusPointFlameRenderer (org.jwildfire.create.tina.render.DrawFocusPointFlameRenderer)2 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 MouseEvent (java.awt.event.MouseEvent)1 MouseWheelEvent (java.awt.event.MouseWheelEvent)1 MouseWheelListener (java.awt.event.MouseWheelListener)1 EmptyBorder (javax.swing.border.EmptyBorder)1 Prefs (org.jwildfire.base.Prefs)1 ComposeTransformer (org.jwildfire.transform.ComposeTransformer)1