Search in sources :

Example 1 with MapGradientReader

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

the class MapFilePreview method createThumbnail.

public void createThumbnail() {
    if (currFile == null) {
        currThumbnail = null;
        return;
    }
    try {
        if (currFile.exists()) {
            List<RGBPalette> gradients = new MapGradientReader().readPalettes(currFile.getAbsolutePath());
            int imgWidth = this.getPreferredSize().width;
            int imgHeight = this.getPreferredSize().height - BUTTON_HEIGHT;
            SimpleImage img = new RGBPaletteRenderer().renderHorizPalette(gradients.get(0), imgWidth, imgHeight);
            currThumbnail = new ImageIcon(img.getBufferedImg());
        }
    } catch (Exception ex) {
        currThumbnail = null;
        if (ex.getCause() != null) {
            ex.getCause().printStackTrace();
        } else {
            ex.printStackTrace();
        }
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) MapGradientReader(org.jwildfire.create.tina.io.MapGradientReader) RGBPalette(org.jwildfire.create.tina.palette.RGBPalette) SimpleImage(org.jwildfire.image.SimpleImage) RGBPaletteRenderer(org.jwildfire.create.tina.palette.RGBPaletteRenderer)

Aggregations

ImageIcon (javax.swing.ImageIcon)1 MapGradientReader (org.jwildfire.create.tina.io.MapGradientReader)1 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)1 RGBPaletteRenderer (org.jwildfire.create.tina.palette.RGBPaletteRenderer)1 SimpleImage (org.jwildfire.image.SimpleImage)1