use of org.jwildfire.create.tina.render.image.RenderImageSimpleThread in project JWildfire by thargor6.
the class FlameRenderer method renderImageSimple.
private void renderImageSimple(SimpleImage pImage) {
int threadCount = prefs.getTinaRenderThreads();
if (threadCount < 1)
threadCount = 1;
logDensityFilter.setRaster(raster, rasterWidth, rasterHeight, pImage.getImageWidth(), pImage.getImageHeight());
if (renderScale == 2) {
SimpleImage newImg = new SimpleImage(pImage.getImageWidth() * renderScale, pImage.getImageHeight() * renderScale);
int rowsPerThread = pImage.getImageHeight() / threadCount;
List<RenderImageSimpleScaledThread> threads = new ArrayList<RenderImageSimpleScaledThread>();
for (int i = 0; i < threadCount; i++) {
int startRow = i * rowsPerThread;
int endRow = i < threadCount - 1 ? startRow + rowsPerThread : pImage.getImageHeight();
RenderImageSimpleScaledThread thread = new RenderImageSimpleScaledThread(flame, logDensityFilter, gammaCorrectionFilter, renderScale, startRow, endRow, pImage, newImg);
threads.add(thread);
if (threadCount > 1) {
new Thread(thread).start();
} else {
thread.run();
}
}
ThreadTools.waitForThreads(threadCount, threads);
pImage.setBufferedImage(newImg.getBufferedImg(), newImg.getImageWidth(), newImg.getImageHeight());
} else if (renderScale == 1) {
int rowsPerThread = pImage.getImageHeight() / threadCount;
List<RenderImageSimpleThread> threads = new ArrayList<RenderImageSimpleThread>();
for (int i = 0; i < threadCount; i++) {
int startRow = i * rowsPerThread;
int endRow = i < rowsPerThread - 1 ? startRow + rowsPerThread : pImage.getImageHeight();
RenderImageSimpleThread thread = new RenderImageSimpleThread(flame, logDensityFilter, gammaCorrectionFilter, startRow, endRow, pImage);
threads.add(thread);
if (threadCount > 1) {
new Thread(thread).start();
} else {
thread.run();
}
}
ThreadTools.waitForThreads(threadCount, threads);
} else {
throw new IllegalArgumentException("renderScale " + renderScale);
}
}
Aggregations