use of org.jwildfire.create.tina.base.Flame in project JWildfire by thargor6.
the class FlameControlsDelegate method stereo3dPreviewCmb_changed.
public void stereo3dPreviewCmb_changed() {
if (!isNoRefresh()) {
Flame flame = getCurrFlame();
if (flame != null) {
owner.saveUndoPoint();
flame.setStereo3dPreview((Stereo3dPreview) data.stereo3dPreviewCmb.getSelectedItem());
enableStereo3dUI();
owner.refreshFlameImage(true, false, 1, true, false);
}
}
}
use of org.jwildfire.create.tina.base.Flame in project JWildfire by thargor6.
the class FlameControlsDelegate method postSymmetryCmb_changed.
public void postSymmetryCmb_changed() {
if (!isNoRefresh()) {
Flame flame = getCurrFlame();
if (flame != null) {
owner.saveUndoPoint();
flame.setPostSymmetryType((PostSymmetryType) data.postSymmetryTypeCmb.getSelectedItem());
enablePostSymmetryUI();
owner.refreshFlameImage(true, false, 1, true, false);
}
}
}
use of org.jwildfire.create.tina.base.Flame in project JWildfire by thargor6.
the class FlameFilePreview method createThumbnail.
public void createThumbnail() {
if (currFile == null) {
currThumbnail = null;
return;
}
try {
if (currFile.exists()) {
int imgWidth = this.getPreferredSize().width;
int imgHeight = this.getPreferredSize().height - BUTTON_HEIGHT;
int quality = 50;
SimpleImage preview;
String filename = currFile.getAbsolutePath();
ThumbnailCacheKey cacheKey = new ThumbnailCacheKey(filename);
preview = ThumbnailCacheProvider.getThumbnail(cacheKey, imgWidth, imgHeight, quality);
if (preview == null) {
List<Flame> flames = new FlameReader(prefs).readFlames(filename);
Flame flame = flames.get(0);
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(quality);
flame.setSpatialFilterRadius(0.0);
RenderInfo info = new RenderInfo(imgWidth, imgHeight, RenderMode.PREVIEW);
RenderedFlame res = renderer.renderFlame(info);
preview = res.getImage();
ThumbnailCacheProvider.storeThumbnail(cacheKey, imgWidth, imgHeight, quality, preview);
}
currThumbnail = new ImageIcon(preview.getBufferedImg());
}
} catch (Exception ex) {
currThumbnail = null;
if (ex.getCause() != null) {
ex.getCause().printStackTrace();
} else {
ex.printStackTrace();
}
}
}
use of org.jwildfire.create.tina.base.Flame 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;
}
use of org.jwildfire.create.tina.base.Flame 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;
}
Aggregations