Search in sources :

Example 1 with RGBPaletteRenderer

use of org.jwildfire.create.tina.palette.RGBPaletteRenderer 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)

Example 2 with RGBPaletteRenderer

use of org.jwildfire.create.tina.palette.RGBPaletteRenderer in project JWildfire by thargor6.

the class TinaController method refreshPaletteImg.

private void refreshPaletteImg() {
    try {
        if (getCurrLayer() != null) {
            ImagePanel[] panels = { getPalettePanel(), getColorChooserPalettePanel() };
            for (ImagePanel imgPanel : panels) {
                int width = imgPanel.getWidth();
                int height = imgPanel.getHeight();
                if (width >= 16 && height >= 4) {
                    if (getCurrLayer().getGradientMapFilename() != null && getCurrLayer().getGradientMapFilename().length() > 0) {
                        SimpleImage img = (SimpleImage) RessourceManager.getImage(getCurrLayer().getGradientMapFilename());
                        imgPanel.setImage(img, 0, 0, width, height);
                    } else {
                        SimpleImage img = new RGBPaletteRenderer().renderHorizPalette(getCurrLayer().getPalette(), width, height);
                        imgPanel.setImage(img);
                    }
                }
                imgPanel.getParent().validate();
                imgPanel.repaint();
            }
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) RGBPaletteRenderer(org.jwildfire.create.tina.palette.RGBPaletteRenderer) ImagePanel(org.jwildfire.swing.ImagePanel)

Aggregations

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