Search in sources :

Example 6 with FilteredImageSource

use of java.awt.image.FilteredImageSource in project cayenne by apache.

the class FilteredIconFactory method createIcon.

public static Icon createIcon(Icon icon, FilterType filterType) {
    if (icon != null && icon.getIconWidth() > 0 && icon.getIconHeight() > 0) {
        BufferedImage img = new BufferedImage(icon.getIconWidth(), icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
        icon.paintIcon(DUMMY, img.getGraphics(), 0, 0);
        ImageProducer producer = new FilteredImageSource(img.getSource(), filterType.filter);
        Image resultImage = DUMMY.createImage(producer);
        return new ImageIcon(resultImage);
    }
    return null;
}
Also used : ImageIcon(javax.swing.ImageIcon) ImageProducer(java.awt.image.ImageProducer) FilteredImageSource(java.awt.image.FilteredImageSource) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) BufferedImage(java.awt.image.BufferedImage)

Aggregations

FilteredImageSource (java.awt.image.FilteredImageSource)6 ImageProducer (java.awt.image.ImageProducer)5 BufferedImage (java.awt.image.BufferedImage)2 ImageFilter (java.awt.image.ImageFilter)2 RGBImageFilter (java.awt.image.RGBImageFilter)2 ImageIcon (javax.swing.ImageIcon)2 Dimension (java.awt.Dimension)1 Image (java.awt.Image)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 AreaAveragingScaleFilter (java.awt.image.AreaAveragingScaleFilter)1 ReplicateScaleFilter (java.awt.image.ReplicateScaleFilter)1 JButton (javax.swing.JButton)1 ImageIconUIResource (sun.swing.ImageIconUIResource)1