Search in sources :

Example 96 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class FlameControlsDelegate method refreshReflMapColorIndicator.

private void refreshReflMapColorIndicator() {
    MaterialSettings material = getSolidRenderingSelectedMaterial();
    Color color = Color.BLACK;
    if (material != null && material.getReflMapFilename() != null && !material.getReflMapFilename().isEmpty()) {
        try {
            WFImage img = RessourceManager.getImage(material.getReflMapFilename());
            if (img instanceof SimpleImage) {
                SimpleImage sImg = (SimpleImage) img;
                int samples = 6;
                int dx = sImg.getImageWidth() / samples;
                int dy = sImg.getImageHeight() / samples;
                double r = 0.0, g = 0.0, b = 0.0;
                for (int x = 0; x < sImg.getImageWidth(); x += dx) {
                    for (int y = 0; y < sImg.getImageHeight(); y += dy) {
                        r += sImg.getRValue(x, y);
                        g += sImg.getGValue(x, y);
                        b += sImg.getBValue(x, y);
                    }
                }
                color = new Color(Tools.roundColor(r / (samples * samples)), Tools.roundColor(g / (samples * samples)), Tools.roundColor(b / (samples * samples)));
            } else {
                color = Color.RED;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    data.tinaSolidRenderingMaterialReflMapBtn.setBackground(color);
}
Also used : WFImage(org.jwildfire.image.WFImage) MaterialSettings(org.jwildfire.create.tina.base.solidrender.MaterialSettings) Color(java.awt.Color) RGBColor(org.jwildfire.create.tina.palette.RGBColor) Stereo3dColor(org.jwildfire.create.tina.base.Stereo3dColor) SimpleImage(org.jwildfire.image.SimpleImage)

Example 97 with SimpleImage

use of org.jwildfire.image.SimpleImage 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 98 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class FlamePreviewHelper method initImage.

private void initImage(SimpleImage pImage, Flame flame) {
    if (flame.getBGImageFilename() != null && !flame.getBGImageFilename().isEmpty()) {
        try {
            SimpleImage bgImg = (SimpleImage) RessourceManager.getImage(flame.getBGImageFilename());
            pImage.fillBackground(bgImg);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    } else {
        new FlameBGColorHandler(flame).fillBackground(pImage);
    }
}
Also used : FlameBGColorHandler(org.jwildfire.create.tina.render.FlameBGColorHandler) SimpleImage(org.jwildfire.image.SimpleImage)

Example 99 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class FlamePreviewHelper method fastRefreshFlameImage.

public void fastRefreshFlameImage(boolean pQuickRender, boolean pMouseDown, int pDownScale) {
    FlamePanel imgPanel = flamePanelProvider.getFlamePanel();
    SimpleImage img = fastRenderFlameImage(pQuickRender, pMouseDown, pDownScale);
    if (img != null) {
        imgPanel.setImage(img);
    }
    imgPanel.repaint();
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel)

Example 100 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class FlamePreviewHelper method refreshFlameImage.

public void refreshFlameImage(boolean pQuickRender, boolean pMouseDown, int pDownScale, boolean pReRender, boolean pAllowUseCache) {
    cancelBackgroundRender();
    if (pQuickRender && detachedPreviewProvider != null && detachedPreviewProvider.getDetachedPreviewController() != null && pDownScale == 1) {
        detachedPreviewProvider.getDetachedPreviewController().setFlame(flameHolder.getFlame());
    }
    FlamePanel imgPanel = flamePanelProvider.getFlamePanel();
    FlamePanelConfig cfg = flamePanelProvider.getFlamePanelConfig();
    if (pReRender) {
        if (!pQuickRender || !isProgressivePreviewEnabled(cfg)) {
            SimpleImage img = renderFlameImage(pQuickRender, pMouseDown, pDownScale, pAllowUseCache);
            if (img != null) {
                imgPanel.setImage(img);
            }
        }
    }
    imgPanel.setBounds(imgPanel.getParentImageBounds());
    if (!cfg.isNoControls()) {
        centerPanel.getParent().validate();
        centerPanel.repaint();
    } else {
        imgPanel.repaint();
    }
    if (pReRender && isProgressivePreviewEnabled(cfg) && pQuickRender) {
        if (pAllowUseCache) {
            SimpleImage img = renderFlameImage(pQuickRender, pMouseDown, pDownScale, pAllowUseCache);
            if (img != null) {
                imgPanel.setImage(img);
            }
        } else {
            startBackgroundRender(imgPanel);
        }
    }
    if (pQuickRender && !cfg.isNoControls() && randomBatchHolder != null) {
        refreshThumbnail();
    }
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel) FlamePanelConfig(org.jwildfire.create.tina.swing.flamepanel.FlamePanelConfig)

Aggregations

SimpleImage (org.jwildfire.image.SimpleImage)174 Pixel (org.jwildfire.image.Pixel)37 ImagePanel (org.jwildfire.swing.ImagePanel)24 FlamePanel (org.jwildfire.create.tina.swing.flamepanel.FlamePanel)20 Dimension (java.awt.Dimension)18 Flame (org.jwildfire.create.tina.base.Flame)17 File (java.io.File)16 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)16 ArrayList (java.util.ArrayList)14 Rectangle (java.awt.Rectangle)12 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)12 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)12 Graphics (java.awt.Graphics)10 SimpleHDRImage (org.jwildfire.image.SimpleHDRImage)10 WFImage (org.jwildfire.image.WFImage)9 ImageReader (org.jwildfire.io.ImageReader)9 JPanel (javax.swing.JPanel)8 JScrollPane (javax.swing.JScrollPane)8 ResolutionProfile (org.jwildfire.base.ResolutionProfile)8 Color (java.awt.Color)7