Search in sources :

Example 1 with FastHDRTonemapper

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();
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) SimpleHDRImage(org.jwildfire.image.SimpleHDRImage) SimpleImage(org.jwildfire.image.SimpleImage) FastHDRTonemapper(org.jwildfire.image.FastHDRTonemapper) ScaleTransformer(org.jwildfire.transform.ScaleTransformer) ImageReader(org.jwildfire.io.ImageReader)

Aggregations

ImageIcon (javax.swing.ImageIcon)1 FastHDRTonemapper (org.jwildfire.image.FastHDRTonemapper)1 SimpleHDRImage (org.jwildfire.image.SimpleHDRImage)1 SimpleImage (org.jwildfire.image.SimpleImage)1 ImageReader (org.jwildfire.io.ImageReader)1 ScaleTransformer (org.jwildfire.transform.ScaleTransformer)1