Java examples for 2D Graphics:Image Convert
get Gray Picture
//package com.java2s; import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; import java.awt.image.ColorConvertOp; public class Main { public static BufferedImage getGrayPicture(BufferedImage originalImage) { int imageWidth = originalImage.getWidth(); int imageHeight = originalImage.getHeight(); BufferedImage grayPicture = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_3BYTE_BGR); ColorConvertOp cco = new ColorConvertOp( ColorSpace.getInstance(ColorSpace.CS_GRAY), null); cco.filter(originalImage, grayPicture); return grayPicture; }//from ww w .j a v a 2 s .c o m }