use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.
the class RealtimeAnimRenderThread method run.
@Override
public void run() {
setRunning(forceAbort = false);
try {
long fpsMeasureMentFrameCount = 0;
long startFPSMeasurement = System.currentTimeMillis();
long nextFrame = timeRenderStarted = startFPSMeasurement;
double fps = 0.0;
setRunning(true);
while (!forceAbort) {
long time = System.currentTimeMillis();
while (time < nextFrame) {
try {
Thread.sleep(1);
} catch (Exception ex) {
ex.printStackTrace();
}
time = System.currentTimeMillis();
}
nextFrame = (long) (time + 1000.0 / (double) getFramesPerSecond() + 0.5);
DancingFlame dancingFlame = flameStack.getFlame();
currFlame = null;
short[] currFFT;
if (fftData != null) {
currFFT = fftData.getData(musicPlayer.getPosition());
if (drawFFT && fftPanel != null) {
SimpleImage img = fftPanel.getImage();
drawFFT(img, currFFT);
fftPanel.repaint();
}
} else {
currFFT = null;
}
long elapsedTime = time - timeRenderStarted;
if (dancingFlame != null) {
currFlame = transformer.createTransformedFlame(dancingFlame, currFFT, elapsedTime, getFramesPerSecond());
}
fpsMeasureMentFrameCount++;
long dt = (System.currentTimeMillis() - startFPSMeasurement);
if (dt > 500) {
fps = (double) (fpsMeasureMentFrameCount * 1000.0) / (double) dt;
fpsMeasureMentFrameCount = 0;
startFPSMeasurement = System.currentTimeMillis();
}
if (currFlame != null) {
try {
controller.refreshFlameImage(currFlame, drawTriangles, fps, elapsedTime, drawFPS);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
} finally {
setRunning(false);
}
}
use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.
the class CacheRendererThread method run.
@Override
public void run() {
done = false;
cancelSignalled = false;
try {
for (RenderJobInfo job : jobs) {
try {
if (cancelSignalled) {
break;
}
SimpleImage img = renderFlame(job.getFlame(), job.getRenderWidth(), job.getRenderHeight());
renderCache.putImage(job.getFlame(), img, job.getRenderWidth(), job.getRenderHeight());
job.getDestPnl().setImage(img);
job.getDestPnl().setLocation(job.getLocationX(), job.getLocationY());
redraw((JPanel) job.getDestPnl());
} catch (Exception ex) {
ex.printStackTrace();
}
}
} finally {
done = true;
}
}
use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.
the class FlameBrowserController method deleteBtn_clicked.
public void deleteBtn_clicked() {
FlameFlatNode node = getSelectedFlame();
if (node != null) {
try {
if (StandardDialogs.confirm(rootPanel, "Do you really want to permanently delete this flame?")) {
File file = new File(node.getFilename());
if (!file.delete()) {
throw new Exception("Could not delete file");
}
node.setRemoved(false);
ImagePanel pnl = pnlList.get(selectedPnl);
SimpleImage img = pnl.getImage();
TextTransformer txt = new TextTransformer();
txt.setText1("(deleted)");
txt.setAntialiasing(true);
txt.setColor(Color.RED);
txt.setMode(Mode.NORMAL);
txt.setFontStyle(FontStyle.BOLD);
txt.setFontName("Arial");
txt.setFontSize(24);
txt.setHAlign(HAlignment.CENTRE);
txt.setVAlign(VAlignment.CENTRE);
txt.transformImage(img);
pnl.invalidate();
pnl.repaint();
}
} catch (Exception ex) {
errorHandler.handleError(ex);
}
}
}
use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.
the class FlameRenderer method renderStereo3dSideBySide.
private RenderedFlame renderStereo3dSideBySide(RenderInfo pRenderInfo) {
RenderInfo localRenderInfo = pRenderInfo.makeCopy();
localRenderInfo.setRenderHDR(false);
localRenderInfo.setRenderZBuffer(false);
eye = Stereo3dEye.LEFT;
RenderedFlame leftRender = renderImageNormal(localRenderInfo, 2, 0);
eye = Stereo3dEye.RIGHT;
RenderedFlame rightRender = renderImageNormal(localRenderInfo, 2, 1);
if (flame.isStereo3dSwapSides()) {
RenderedFlame tmp = leftRender;
leftRender = rightRender;
rightRender = tmp;
}
RenderedFlame mergedRender = new RenderedFlame();
localRenderInfo.setImageWidth(2 * leftRender.getImage().getImageWidth());
localRenderInfo.setImageHeight(leftRender.getImage().getImageHeight());
mergedRender.init(localRenderInfo, flame);
SimpleImage mergedImg = mergedRender.getImage();
ComposeTransformer composeTransformer = new ComposeTransformer();
composeTransformer.setHAlign(HAlignment.OFF);
composeTransformer.setVAlign(VAlignment.OFF);
composeTransformer.setForegroundImage(leftRender.getImage());
composeTransformer.transformImage(mergedImg);
composeTransformer.setForegroundImage(rightRender.getImage());
composeTransformer.setLeft(leftRender.getImage().getImageWidth());
composeTransformer.transformImage(mergedImg);
return mergedRender;
}
use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.
the class FlameRenderer method renderImageNormal.
private RenderedFlame renderImageNormal(RenderInfo pRenderInfo, int pTotalImagePartCount, int pTotalImagePartIdx) {
progressDisplayPhaseCount = pTotalImagePartCount;
progressDisplayPhase = pTotalImagePartIdx;
RenderedFlame res = new RenderedFlame();
res.init(pRenderInfo, flame);
if (forceAbort)
return res;
boolean renderNormal = true;
boolean renderHDR = pRenderInfo.isRenderHDR();
if (!flame.isRenderable()) {
if (renderNormal) {
if (renderScale > 0) {
res.getImage().resetImage(res.getImage().getImageWidth() * renderScale, res.getImage().getImageHeight() * renderScale);
}
if (flame.getBGImageFilename().length() > 0) {
try {
res.getImage().fillBackground((SimpleImage) RessourceManager.getImage(flame.getBGImageFilename()));
} catch (Exception ex) {
ex.printStackTrace();
}
} else {
new FlameBGColorHandler(flame).fillBackground(res.getImage());
}
}
if (renderHDR) {
res.getHDRImage().fillBackground(flame.getBgColorRed(), flame.getBgColorGreen(), flame.getBgColorBlue());
try {
res.getHDRImage().fillBackground((SimpleImage) RessourceManager.getImage(flame.getBGImageFilename()));
} catch (Exception ex) {
ex.printStackTrace();
}
}
return res;
}
double origZoom = flame.getCamZoom();
try {
SimpleImage img = renderNormal ? res.getImage() : null;
SimpleHDRImage hdrImg = renderHDR ? res.getHDRImage() : null;
if (renderNormal) {
initRaster(pRenderInfo, img.getImageWidth(), img.getImageHeight(), flame.getSampleDensity());
} else if (renderHDR) {
initRaster(pRenderInfo, hdrImg.getImageWidth(), hdrImg.getImageHeight(), flame.getSampleDensity());
} else {
throw new IllegalStateException();
}
if (pRenderInfo.getRestoredRaster() == null) {
List<List<RenderPacket>> renderFlames = new ArrayList<List<RenderPacket>>();
for (int t = 0; t < prefs.getTinaRenderThreads(); t++) {
renderFlames.add(createRenderPackets(flame, flame.getFrame()));
}
forceAbort = false;
iterate(0, 1, renderFlames, null);
raster.finalizeRaster();
if (pRenderInfo.isStoreRaster()) {
res.setRaster(raster);
}
} else {
if (flame.getSolidRenderSettings().isSolidRenderingEnabled()) {
FlameRendererView view = createView(flame);
raster.notifyInit(view.getLightViewCalculator());
}
}
if (!forceAbort) {
if ((flame.getSampleDensity() <= 10.0 && flame.getSpatialFilterRadius() <= MathLib.EPSILON) || renderScale > 1) {
renderImageSimple(img);
} else {
renderImage(img, hdrImg, res.getZBuffer());
}
}
} finally {
flame.setCamZoom(origZoom);
}
return res;
}
Aggregations