Java 8 FilteredImageSource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 FilteredImageSource class.

This code example shows how to use the following methods:
                    return rgb;
                } 
            } 
        }; 
 
        ImageProducer ip = new FilteredImageSource(im.getSource(), filter);
        return Toolkit.getDefaultToolkit().createImage(ip);
    } 
 
    public static BufferedImage makeImageTranslucent(BufferedImage source,
            double alpha) {
        BufferedImage target = new BufferedImage(source.getWidth(), source
                .getHeight(), java.awt.Transparency.TRANSLUCENT);
        // Get the images graphics 
        Graphics2D g = target.createGraphics();
        // Set the Graphics composite to Alpha 
        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
                (float) alpha));
        // Draw the image into the prepared reciver image 
        g.drawImage(source, null, 0, 0);
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
     * @param insets the insets. The border area with the insets will not be tinted. 
     * @return a tinted image 
     */ 
    public static Image createTintedImage(Image i, Color color, Insets insets) {
        TintFilter filter = new TintFilter(color, i.getWidth(null), i.getHeight(null), insets);
        ImageProducer prod = new FilteredImageSource(i.getSource(), filter);
        return Toolkit.getDefaultToolkit().createImage(prod);
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    /** 
     * Creates an image from an existing one by replacing the old color with the new color. 
     */ 
    public static Image createImage(Image i, Color oldColor, Color newColor) {
        MaskFilter filter = MaskFilter.getInstance(oldColor, newColor);
        ImageProducer prod = new FilteredImageSource(i.getSource(), filter);
        Image image = Toolkit.getDefaultToolkit().createImage(prod);
        return image;
    } 
 
    /** 
     * Creates an image as negative of an existing one. It will basically replace the black color with white color. 
     */ 
    public static Image createNegativeImage(Image i) {
        return createImage(i, Color.black, Color.white);
    } 
 
    /** 
     * Constructs a MaskFilter object that filters color of image to another color Please note, you can also use {@link 
     * #getInstance(java.awt.Color, java.awt.Color)} to reuse the same instance of MaskFilter. 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
     * 
     * @return a brighter image 
     */ 
    public static Image createBrighterImage(Image i) {
        ColorFilter filter = ColorFilter.getInstance(true, _percent);
        ImageProducer prod = new FilteredImageSource(i.getSource(), filter);
        return Toolkit.getDefaultToolkit().createImage(prod);
    } 
 
    /** 
     * Creates a brighter image with a given percentage of brightness 
     * 
     * @param i the original image 
     * @param p percentage of brightness 
     * 
     * @return a brighter image 
     */ 
    public static Image createBrighterImage(Image i, int p) {
        setPercent(p);
        return createBrighterImage(i);
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
     * @param image The image to disable 
     * @return The disabled (grayed) version of the specified image, brightened by 20%. 
     * @since 5484 
     */ 
    public static final Image getDisabledImage(Image image) {
        return Toolkit.getDefaultToolkit().createImage(
                new FilteredImageSource(image.getSource(), new GrayFilter(true, 20)));
    } 
 
    /** 
     * Replies the disabled (grayed) version of the specified icon. 
     * @param icon The icon to disable 
     * @return The disabled (grayed) version of the specified icon, brightened by 20%. 
     * @since 5484 
     */ 
    public static final ImageIcon getDisabledIcon(ImageIcon icon) {
        return new ImageIcon(getDisabledImage(icon.getImage()));
    } 
 
    /** 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    @Override 
    public BufferedImage getSicknessImage() {
        if (imageSickness == null) {
            Image image = getImageFromResourceTransparent("/sickness.png", Color.WHITE, new Rectangle(296, 265));
            Toolkit tk = Toolkit.getDefaultToolkit();
            image = tk.createImage(new FilteredImageSource(image.getSource(), new CropImageFilter(0, 0, 200, 285)));
            imageSickness = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB);
        } 
        return imageSickness;
    } 
 
    @Override 
    public BufferedImage getDayImage() {
        if (imageDay == null) {
            Image image = getImageFromResourceTransparent("/card/day.png", Color.WHITE, new Rectangle(20, 20));
            imageDay = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB);
        } 
        return imageDay;
    } 
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        if (template == null) {
            return null; 
        } 
        final java.awt.Image iconImage = template.getIcon(height);
        if (tint != null) {
            Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(iconImage.getSource(), new Filter()));
        } 
        final Image icon = new AwtImage(iconImage);
        return icon;
    } 
 
    // //////////////////////////////////////////////////////////////////// 
    // Helpers 
    // //////////////////////////////////////////////////////////////////// 
 
    private TemplateImage templateImage(final String name) {
        final TemplateImage template = loader.getTemplateImage(name);
        return template;
    } 
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
This code example shows how to use the following methods:
    /** 
     * Manipulates an image. 
     */ 
    public static Image manipulate(Image img, boolean brighten, int percent) {
    	ImageFilter filter = new ImageManipulator(brighten, percent);
    	ImageProducer prod = new FilteredImageSource(img.getSource(), filter);
    	return Toolkit.getDefaultToolkit().createImage(prod);
    } 
     
    /** 
     * Resizes an icon. 
     */ 
    public static Icon resize(Icon icon, int width, int height) {
        Image image = getImage(icon);
        if(image == null)
            return icon;
        image = image.getScaledInstance(width, height, Image.SCALE_SMOOTH);
        return new ImageIcon(image);
    } 
     
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    /** 
     * Creates a disabled image 
     */ 
    public static Image createDisabledImage(final Image i) {
        final WhiteFilter filter = new WhiteFilter();
        final ImageProducer prod = new FilteredImageSource(i.getSource(), filter);
 
        return Toolkit.getDefaultToolkit().createImage(prod);
    } 
 
    /** 
     * Overrides <code>RGBImageFilter.filterRGB</code>. 
     */ 
    public int filterRGB(final int x, final int y, final int rgb) {
        int transparency = (rgb >> 24) & 0xFF;
 
        if (transparency <= 1) {
            return rgb; // do not alter fully transparent pixels (those would end up being black)
        } 
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 FilteredImageSource Methods: