java实现彩色图转变为灰度图计算机等级考试
文章作者 100test 发表时间 2010:01:01 12:29:54
来源 100Test.Com百考试题网
package work.
import java.awt.Graphics2D.
import java.awt.RenderingHints.
import java.awt.color.ColorSpace.
import java.awt.image.BufferedImage.
import java.awt.image.ColorConvertOp.
import java.io.File.
import java.io.IOException.
import javax.imageio.ImageIO.
public class Gray {
public static void main(String[] args) throws IOException
{
BufferedImage transforImage.
BufferedImage finalImage.
TransGray gray=new TransGray().
transforImage=gray.srcImage.
finalImage=gray.transformGrayJ2D(transforImage,null).//这里可能有问题,关于RenderingHints的取值不是很清楚
File f1=new File("f:/2graychange.jpg").//新图像输出
ImageIO.write(finalImage,"jpg",f1).
System.out.println("End").
}
}
class TransGray
{
int width.
int height.
BufferedImage srcImage.