Search in sources :

Example 1 with JWFRenderHeaderReader

use of org.jwildfire.create.tina.io.JWFRenderHeaderReader in project JWildfire by thargor6.

the class JWFRenderFilePreview method createThumbnail.

public void createThumbnail() {
    if (currFile == null) {
        currThumbnail = null;
        return;
    }
    try {
        if (currFile.exists()) {
            JWFRenderHeader header = new JWFRenderHeaderReader().readRenderHeader(currFile.getAbsolutePath());
            Flame flame = header.getFlame();
            if (flame != null) {
                int imgWidth = this.getPreferredSize().width;
                int imgHeight = this.getPreferredSize().height;
                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(50);
                flame.setSpatialFilterRadius(0.0);
                RenderInfo info = new RenderInfo(imgWidth, imgHeight, RenderMode.PREVIEW);
                RenderedFlame res = renderer.renderFlame(info);
                currThumbnail = new ImageIcon(res.getImage().getBufferedImg());
            }
        }
    } catch (Exception ex) {
        currThumbnail = null;
        if (ex.getCause() != null) {
            ex.getCause().printStackTrace();
        } else {
            ex.printStackTrace();
        }
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) JWFRenderHeader(org.jwildfire.create.tina.io.JWFRenderHeader) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) JWFRenderHeaderReader(org.jwildfire.create.tina.io.JWFRenderHeaderReader) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Aggregations

ImageIcon (javax.swing.ImageIcon)1 Flame (org.jwildfire.create.tina.base.Flame)1 JWFRenderHeader (org.jwildfire.create.tina.io.JWFRenderHeader)1 JWFRenderHeaderReader (org.jwildfire.create.tina.io.JWFRenderHeaderReader)1 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)1 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)1 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)1