Example usage for java.awt.image FilteredImageSource FilteredImageSource

List of usage examples for java.awt.image FilteredImageSource FilteredImageSource

Introduction

In this page you can find the example usage for java.awt.image FilteredImageSource FilteredImageSource.

Prototype

public FilteredImageSource(ImageProducer orig, ImageFilter imgf) 

Source Link

Document

Constructs an ImageProducer object from an existing ImageProducer and a filter object.

Usage

From source file:GetRedFilter.java

public static void main(String[] argv) throws Exception {
    Image image = new ImageIcon("image.gif").getImage();
    ImageFilter filter = new GetRedFilter();
    FilteredImageSource filteredSrc = new FilteredImageSource(image.getSource(), filter);
    image = Toolkit.getDefaultToolkit().createImage(filteredSrc);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String mapUrlPath = "http://www.java2s.com/style/download.png";
    URL mapUrl = new URL(mapUrlPath);
    BufferedImage mapImage = ImageIO.read(mapUrl);
    Image newMapImage = Toolkit.getDefaultToolkit()
            .createImage(new FilteredImageSource(mapImage.getSource(), new RedBlueSwapFilter()));
    ImageIcon mapIcon = new ImageIcon(mapImage);
    ImageIcon newMapIcon = new ImageIcon(newMapImage);

    JPanel imagePanel = new JPanel();
    imagePanel.add(new JLabel(mapIcon));
    imagePanel.add(new JLabel(newMapIcon));

    JOptionPane.showMessageDialog(null, imagePanel);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String mapUrlPath = "http://www.java2s.com/style/download.png";
    URL mapUrl = new URL(mapUrlPath);
    BufferedImage mapImage = ImageIO.read(mapUrl);
    Image newMapImage = Toolkit.getDefaultToolkit()
            .createImage(new FilteredImageSource(mapImage.getSource(), new XorFilter()));
    ImageIcon mapIcon = new ImageIcon(mapImage);
    ImageIcon newMapIcon = new ImageIcon(newMapImage);

    JPanel imagePanel = new JPanel();
    imagePanel.add(new JLabel(mapIcon));
    imagePanel.add(new JLabel(newMapIcon));

    JOptionPane.showMessageDialog(null, imagePanel);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String mapUrlPath = "http://www.java2s.com/style/download.png";
    URL mapUrl = new URL(mapUrlPath);
    BufferedImage mapImage = ImageIO.read(mapUrl);
    Image newMapImage = Toolkit.getDefaultToolkit()
            .createImage(new FilteredImageSource(mapImage.getSource(), new GrayFilter()));
    ImageIcon mapIcon = new ImageIcon(mapImage);
    ImageIcon newMapIcon = new ImageIcon(newMapImage);

    JPanel imagePanel = new JPanel();
    imagePanel.add(new JLabel(mapIcon));
    imagePanel.add(new JLabel(newMapIcon));

    JOptionPane.showMessageDialog(null, imagePanel);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String mapUrlPath = "http://www.java2s.com/style/download.png";
    URL mapUrl = new URL(mapUrlPath);
    BufferedImage mapImage = ImageIO.read(mapUrl);
    Image newMapImage = Toolkit.getDefaultToolkit()
            .createImage(new FilteredImageSource(mapImage.getSource(), new GrayToColorFilter(Color.red)));
    ImageIcon mapIcon = new ImageIcon(mapImage);
    ImageIcon newMapIcon = new ImageIcon(newMapImage);

    JPanel imagePanel = new JPanel();
    imagePanel.add(new JLabel(mapIcon));
    imagePanel.add(new JLabel(newMapIcon));

    JOptionPane.showMessageDialog(null, imagePanel);
}

From source file:Transparency.java

public static Image makeColorTransparent(Image im, final Color color) {
    ImageFilter filter = new RGBImageFilter() {
        // the color we are looking for... Alpha bits are set to opaque
        public int markerRGB = color.getRGB() | 0xFF000000;

        @Override//from  w  ww.  jav  a  2 s  . co m
        public final int filterRGB(int x, int y, int rgb) {
            if ((rgb | 0xFF000000) == markerRGB) {
                // Mark the alpha bits as zero - transparent
                return 0x00FFFFFF & rgb;
            } else {
                // nothing to do
                return rgb;
            }
        }
    };

    ImageProducer ip = new FilteredImageSource(im.getSource(), filter);
    return Toolkit.getDefaultToolkit().createImage(ip);
}

From source file:MainClass.java

public void paint(Graphics g) {
    NegativeFilter nf = new NegativeFilter();

    Image i = createImage(new FilteredImageSource(createImage().getSource(), nf));

    g.drawImage(i, 20, 20, this);
}

From source file:Crop.java

public Crop() {
    super();/*from w ww.  j  ava 2  s  .com*/
    ImageIcon icon = new ImageIcon("java2s.PNG");
    image = icon.getImage();
    image = createImage(new FilteredImageSource(image.getSource(), new CropImageFilter(73, 63, 141, 131)));
}

From source file:MainClass.java

public void init() {
    i = getImage(getDocumentBase(), "rosey.jpg");
    j = createImage(new FilteredImageSource(i.getSource(), new DynamicFilter(250, 5, Color.yellow)));
}

From source file:MainClass.java

public void init() {
    MediaTracker mt = new MediaTracker(this);
    i = getImage(getDocumentBase(), "rosey.jpg");
    mt.addImage(i, 0);/*from  www  .  java  2  s.c o m*/
    try {
        mt.waitForAll();
        int width = i.getWidth(this);
        int height = i.getHeight(this);
        j = createImage(new FilteredImageSource(i.getSource(),
                new CropImageFilter(width / 3, height / 3, width / 3, height / 3)));
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}