Search in sources :

Example 1 with RenderImageSimpleScaledThread

use of org.jwildfire.create.tina.render.image.RenderImageSimpleScaledThread 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);
    }
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) ArrayList(java.util.ArrayList) RenderImageSimpleThread(org.jwildfire.create.tina.render.image.RenderImageSimpleThread) ArrayList(java.util.ArrayList) List(java.util.List) PCPoint(org.jwildfire.create.tina.base.raster.RasterPointCloud.PCPoint) RenderImageSimpleScaledThread(org.jwildfire.create.tina.render.image.RenderImageSimpleScaledThread) RenderImageThread(org.jwildfire.create.tina.render.image.RenderImageThread) RenderHDRImageThread(org.jwildfire.create.tina.render.image.RenderHDRImageThread) RenderImageSimpleScaledThread(org.jwildfire.create.tina.render.image.RenderImageSimpleScaledThread) RenderImageSimpleThread(org.jwildfire.create.tina.render.image.RenderImageSimpleThread) PostFilterImageThread(org.jwildfire.create.tina.render.image.PostFilterImageThread) RenderZBufferThread(org.jwildfire.create.tina.render.image.RenderZBufferThread)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 PCPoint (org.jwildfire.create.tina.base.raster.RasterPointCloud.PCPoint)1 PostFilterImageThread (org.jwildfire.create.tina.render.image.PostFilterImageThread)1 RenderHDRImageThread (org.jwildfire.create.tina.render.image.RenderHDRImageThread)1 RenderImageSimpleScaledThread (org.jwildfire.create.tina.render.image.RenderImageSimpleScaledThread)1 RenderImageSimpleThread (org.jwildfire.create.tina.render.image.RenderImageSimpleThread)1 RenderImageThread (org.jwildfire.create.tina.render.image.RenderImageThread)1 RenderZBufferThread (org.jwildfire.create.tina.render.image.RenderZBufferThread)1 SimpleImage (org.jwildfire.image.SimpleImage)1