Search in sources :

Example 1 with RectangleTransformer

use of org.jwildfire.transform.RectangleTransformer in project JWildfire by thargor6.

the class FlamePreviewHelper method createLayerPreview.

private SimpleImage createLayerPreview(SimpleImage img, int renderScale, int width, int height) {
    FlamePanelConfig cfg = flamePanelProvider.getFlamePanelConfig();
    Flame flame = flameHolder.getFlame();
    Layer onlyVisibleLayer = null;
    for (Layer layer : flameHolder.getFlame().getLayers()) {
        if (layer.isVisible()) {
            if (onlyVisibleLayer == null) {
                onlyVisibleLayer = layer;
            } else {
                onlyVisibleLayer = null;
                break;
            }
        }
    }
    boolean drawSubLayer = flame.getLayers().size() > 1 && layerHolder.getLayer() != null && layerHolder.getLayer() != onlyVisibleLayer && !cfg.isNoControls();
    if (drawSubLayer) {
        Flame singleLayerFlame = new Flame();
        singleLayerFlame.assign(flame);
        singleLayerFlame.getLayers().clear();
        singleLayerFlame.getLayers().add(layerHolder.getLayer().makeCopy());
        singleLayerFlame.getFirstLayer().setVisible(true);
        singleLayerFlame.getFirstLayer().setWeight(1.0);
        RenderInfo lInfo = new RenderInfo(width / 4 * renderScale, height / 4 * renderScale, RenderMode.PREVIEW);
        double lWScl = (double) lInfo.getImageWidth() / (double) singleLayerFlame.getWidth();
        double lHScl = (double) lInfo.getImageHeight() / (double) singleLayerFlame.getHeight();
        singleLayerFlame.setPixelsPerUnit((lWScl + lHScl) * 0.5 * singleLayerFlame.getPixelsPerUnit() * 0.5);
        singleLayerFlame.setWidth(lInfo.getImageWidth());
        singleLayerFlame.setHeight(lInfo.getImageHeight());
        singleLayerFlame.setSampleDensity(prefs.getTinaRenderRealtimeQuality() * 2.0 / 3.0);
        FlameRenderer lRenderer = new FlameRenderer(singleLayerFlame, prefs, false, false);
        RenderedFlame lRes = lRenderer.renderFlame(lInfo);
        SimpleImage layerImg = lRes.getImage();
        boolean drawLayerNumber = true;
        if (drawLayerNumber) {
            RectangleTransformer rT = new RectangleTransformer();
            int textWidth = 28;
            int textHeight = 22;
            int margin = 2;
            rT.setColor(new java.awt.Color(0, 0, 0));
            rT.setLeft(layerImg.getImageWidth() - textWidth - 2 * margin);
            rT.setTop(layerImg.getImageHeight() - textHeight - 2 * margin);
            rT.setThickness(textHeight / 2 + 1);
            rT.setWidth(textWidth);
            rT.setHeight(textHeight);
            rT.transformImage(layerImg);
            TextTransformer txt = new TextTransformer();
            txt.setText1("  " + (flame.getLayers().indexOf(layerHolder.getLayer()) + 1) + "  ");
            txt.setAntialiasing(true);
            txt.setColor(new java.awt.Color(200, 200, 200));
            txt.setMode(Mode.NORMAL);
            txt.setFontStyle(FontStyle.BOLD);
            txt.setFontName("Arial");
            txt.setFontSize(16);
            txt.setHAlign(HAlignment.NONE);
            txt.setPosX(layerImg.getImageWidth() - textWidth - margin);
            txt.setPosY(layerImg.getImageHeight() - textHeight - margin);
            txt.setVAlign(VAlignment.NONE);
            txt.transformImage(layerImg);
        }
        RectangleTransformer rT = new RectangleTransformer();
        rT.setColor(new java.awt.Color(200, 200, 200));
        rT.setLeft(0);
        rT.setTop(0);
        rT.setThickness(3);
        rT.setWidth(lInfo.getImageWidth());
        rT.setHeight(lInfo.getImageHeight());
        rT.transformImage(layerImg);
        return layerImg;
    }
    return null;
}
Also used : Color(java.awt.Color) TextTransformer(org.jwildfire.transform.TextTransformer) Layer(org.jwildfire.create.tina.base.Layer) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) XYZProjectedPoint(org.jwildfire.create.tina.base.XYZProjectedPoint) SimpleImage(org.jwildfire.image.SimpleImage) RectangleTransformer(org.jwildfire.transform.RectangleTransformer) 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)

Aggregations

Color (java.awt.Color)1 Flame (org.jwildfire.create.tina.base.Flame)1 Layer (org.jwildfire.create.tina.base.Layer)1 XYZProjectedPoint (org.jwildfire.create.tina.base.XYZProjectedPoint)1 DrawFocusPointFlameRenderer (org.jwildfire.create.tina.render.DrawFocusPointFlameRenderer)1 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)1 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)1 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)1 FlamePanelConfig (org.jwildfire.create.tina.swing.flamepanel.FlamePanelConfig)1 SimpleImage (org.jwildfire.image.SimpleImage)1 RectangleTransformer (org.jwildfire.transform.RectangleTransformer)1 TextTransformer (org.jwildfire.transform.TextTransformer)1