Java BufferedImage Transform TransformGrayToTransparency(BufferedImage image)

Here you can find the source of TransformGrayToTransparency(BufferedImage image)

Description

Transform Gray To Transparency

License

Open Source License

Declaration

private static Image TransformGrayToTransparency(BufferedImage image) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageFilter;
import java.awt.image.ImageProducer;
import java.awt.image.RGBImageFilter;

public class Main {
    private static Image TransformGrayToTransparency(BufferedImage image) {
        ImageFilter filter = new RGBImageFilter() {
            public final int filterRGB(int x, int y, int rgb) {
                if (rgb == 0) {
                    return 0;
                }/*from  w ww .  jav a2  s .c om*/

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

Related

  1. copyAndTranslateSubimage(BufferedImage src, Rectangle bounds)
  2. getTransformedImage(BufferedImage image, double scaleX, double scaleY, double shearX, double shearY)
  3. transform(BufferedImage image, int numquadrants)
  4. transform(BufferedImage image, int sx, int sy, int dx, int dy)
  5. transform(String originalFile, String thumbnailFile, int thumbWidth, int thumbHeight)
  6. transformGrayToTransparency(BufferedImage image)
  7. transformImage(BufferedImage image, AffineTransform transform)
  8. transformImage(BufferedImage image, AffineTransform transform)
  9. transformImage(BufferedImage image, AffineTransform transform, int newWidth, int newHeight)