Search in sources :

Example 41 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class FlamesGPURenderController method refreshImagePanel.

private void refreshImagePanel() {
    if (imageScrollPane != null) {
        imageRootPanel.remove(imageScrollPane);
        imageScrollPane = null;
    }
    ResolutionProfile profile = getResolutionProfile();
    int width = profile.getWidth();
    int height = profile.getHeight();
    if (quarterSizeButton.isSelected()) {
        width /= 4;
        height /= 4;
    } else if (halveSizeButton.isSelected()) {
        width /= 2;
        height /= 2;
    }
    image = new SimpleImage(width, height);
    image.getBufferedImg().setAccelerationPriority(1.0f);
    image.fillBackground(prefs.getTinaRandomBatchBGColorRed(), prefs.getTinaRandomBatchBGColorGreen(), prefs.getTinaRandomBatchBGColorBlue());
    ImagePanel imagePanel = new ImagePanel(image, 0, 0, image.getImageWidth());
    imagePanel.setSize(image.getImageWidth(), image.getImageHeight());
    imagePanel.setPreferredSize(new Dimension(image.getImageWidth(), image.getImageHeight()));
    imageScrollPane = new JScrollPane(imagePanel);
    imageScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    imageScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    imageRootPanel.add(imageScrollPane, BorderLayout.CENTER);
    imageRootPanel.getParent().validate();
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) JScrollPane(javax.swing.JScrollPane) SimpleImage(org.jwildfire.image.SimpleImage) Dimension(java.awt.Dimension) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 42 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class ImageThumbnail method generatePreview.

private SimpleImage generatePreview() {
    if (cacheKey != null) {
        SimpleImage img = ThumbnailCacheProvider.getThumbnail(cacheKey, IMG_WIDTH);
        if (img != null) {
            return img;
        }
    }
    SimpleImage image;
    try {
        image = ((SimpleImage) RessourceManager.getImage(filename));
        RessourceManager.clearImage(filename);
        ScaleTransformer scaleT = new ScaleTransformer();
        scaleT.setScaleWidth(IMG_WIDTH);
        scaleT.setAspect(ScaleAspect.KEEP_WIDTH);
        scaleT.transformImage(image);
        if (cacheKey != null) {
            ThumbnailCacheProvider.storeThumbnail(cacheKey, IMG_WIDTH, image);
        }
        return image;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) ScaleTransformer(org.jwildfire.transform.ScaleTransformer)

Example 43 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class TinaController method grabPaletteFromImageButton_actionPerformed.

public void grabPaletteFromImageButton_actionPerformed(ActionEvent e) {
    JFileChooser chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
    if (prefs.getInputImagePath() != null) {
        try {
            chooser.setCurrentDirectory(new File(prefs.getInputImagePath()));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    if (chooser.showOpenDialog(centerPanel) == JFileChooser.APPROVE_OPTION) {
        File file = chooser.getSelectedFile();
        try {
            SimpleImage img = new ImageReader(centerPanel).loadImage(file.getAbsolutePath());
            prefs.setLastInputImageFile(file);
            RGBPalette palette = new MedianCutQuantizer().createPalette(img);
            data.paletteKeyFrames = null;
            saveUndoPoint();
            getCurrLayer().setPalette(palette);
            setLastGradient(palette);
            refreshPaletteColorsTable();
            refreshPaletteUI(palette);
            refreshFlameImage(true, false, 1, true, false);
        } catch (Throwable ex) {
            errorHandler.handleError(ex);
        }
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) RGBPalette(org.jwildfire.create.tina.palette.RGBPalette) ImageFileChooser(org.jwildfire.swing.ImageFileChooser) SimpleImage(org.jwildfire.image.SimpleImage) ImageReader(org.jwildfire.io.ImageReader) File(java.io.File) MedianCutQuantizer(org.jwildfire.create.tina.palette.MedianCutQuantizer)

Example 44 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class TinaController method getFilterKernelPreviewPanel.

private ImagePanel getFilterKernelPreviewPanel() {
    if (data.filterKernelPreviewPanel == null) {
        int width = data.filterKernelPreviewRootPnl.getWidth();
        int height = data.filterKernelPreviewRootPnl.getHeight();
        SimpleImage img = new SimpleImage(width, height);
        img.fillBackground(0, 0, 0);
        data.filterKernelPreviewPanel = new ImagePanel(img, 0, 0, data.filterKernelPreviewRootPnl.getWidth());
        data.filterKernelPreviewRootPnl.add(data.filterKernelPreviewPanel, BorderLayout.CENTER);
        data.filterKernelPreviewRootPnl.getParent().validate();
    }
    return data.filterKernelPreviewPanel;
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 45 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class TinaController method countDown.

public void countDown(int pTime) {
    for (int i = pTime; i >= 0; i--) {
        Rectangle bounds = flamePreviewHelper.getPanelBounds();
        SimpleImage img = new SimpleImage((int) bounds.getWidth(), (int) bounds.getHeight());
        TextTransformer txt = new TextTransformer();
        txt.setText1(i > 0 ? String.valueOf(i) : "go!");
        txt.setAntialiasing(true);
        txt.setColor(Color.RED);
        txt.setMode(Mode.NORMAL);
        txt.setFontStyle(FontStyle.BOLD);
        txt.setFontName("Arial");
        txt.setFontSize(64);
        txt.setHAlign(HAlignment.CENTRE);
        txt.setVAlign(VAlignment.CENTRE);
        txt.transformImage(img);
        flamePreviewHelper.setImage(img);
        flamePreviewHelper.forceRepaint();
        try {
            Thread.sleep(i > 0 ? 500 : 50);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) Rectangle(java.awt.Rectangle) TextTransformer(org.jwildfire.transform.TextTransformer)

Aggregations

SimpleImage (org.jwildfire.image.SimpleImage)174 Pixel (org.jwildfire.image.Pixel)37 ImagePanel (org.jwildfire.swing.ImagePanel)24 FlamePanel (org.jwildfire.create.tina.swing.flamepanel.FlamePanel)20 Dimension (java.awt.Dimension)18 Flame (org.jwildfire.create.tina.base.Flame)17 File (java.io.File)16 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)16 ArrayList (java.util.ArrayList)14 Rectangle (java.awt.Rectangle)12 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)12 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)12 Graphics (java.awt.Graphics)10 SimpleHDRImage (org.jwildfire.image.SimpleHDRImage)10 WFImage (org.jwildfire.image.WFImage)9 ImageReader (org.jwildfire.io.ImageReader)9 JPanel (javax.swing.JPanel)8 JScrollPane (javax.swing.JScrollPane)8 ResolutionProfile (org.jwildfire.base.ResolutionProfile)8 Color (java.awt.Color)7