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);
}
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();
}
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);
}
}
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();
}
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();
}
}
Aggregations