Java Image Gray Scale createGrayedImage(Image i, final boolean b, final int p)

Here you can find the source of createGrayedImage(Image i, final boolean b, final int p)

Description

create Grayed Image

License

Open Source License

Declaration

public static Image createGrayedImage(Image i, final boolean b, final int p) 

Method Source Code

//package com.java2s;

import java.awt.Image;

import java.awt.Toolkit;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageFilter;
import java.awt.image.ImageProducer;

import javax.swing.GrayFilter;

public class Main {
    public static Image createGrayedImage(Image i, final boolean b, final int p) {
        ImageFilter filter = new GrayFilter(b, p);
        ImageProducer prod = new FilteredImageSource(i.getSource(), filter);
        Image grayImage = Toolkit.getDefaultToolkit().createImage(prod);
        return grayImage;
    }/*from  w w  w.  java  2 s . c o m*/
}

Related

  1. grayScaleImage(Image img, int percent)
  2. isGrayscale(ImageIcon icon)
  3. makeGrayImage(Image in)