use of org.jwildfire.image.FastHDRTonemapper in project JWildfire by thargor6.
the class ImageFilePreview method createThumbnail.
public void createThumbnail() {
if (currFile == null) {
currThumbnail = null;
return;
}
try {
if (currFile.exists()) {
String fileExt = null;
{
String filename = currFile.getName();
int p = filename.lastIndexOf(".");
if (p >= 0 && p < filename.length() - 2) {
fileExt = filename.substring(p + 1, filename.length());
}
}
if ("hdr".equalsIgnoreCase(fileExt)) {
SimpleHDRImage hdrImg = new ImageReader(this).loadHDRImage(currFile.getAbsolutePath());
SimpleImage img = new FastHDRTonemapper().renderImage(hdrImg);
ScaleTransformer scaleT = new ScaleTransformer();
scaleT.setScaleWidth(THUMBNAIL_WIDTH);
scaleT.setAspect(ScaleAspect.KEEP_WIDTH);
scaleT.setUnit(Unit.PIXELS);
scaleT.transformImage(img);
currThumbnail = new ImageIcon(img.getBufferedImg(), currFile.getName());
} else {
ImageIcon tmpIcon = new ImageIcon(currFile.getPath());
if (tmpIcon != null) {
if (tmpIcon.getIconWidth() > THUMBNAIL_WIDTH) {
currThumbnail = new ImageIcon(tmpIcon.getImage().getScaledInstance(THUMBNAIL_WIDTH, -1, Image.SCALE_DEFAULT));
} else {
currThumbnail = tmpIcon;
}
}
}
}
} catch (Throwable ex) {
ex.printStackTrace();
}
}
Aggregations