use of org.jwildfire.create.tina.io.JWFRenderHeader 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();
}
}
}
Aggregations