Converting a Colored Buffered Image to Gray - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Color

Description

Converting a Colored Buffered Image to Gray

Demo Code

import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.ColorConvertOp;

public class Main {
  public static void main(String[] args) throws Exception {
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
    ColorConvertOp op = new ColorConvertOp(cs, null);
    /*from ww w .jav a2 s  . com*/
    BufferedImage bufferedImage = null;
    bufferedImage = op.filter(bufferedImage, null);
  }
}

Related Tutorials