1
image = ImageIO.read(new File("C:/Graphics/src/name2.jpg"));         

ImageFilter filter = new CropImageFilter(0, 0, 250, 250);
    ImageProducer producer = new FilteredImageSource(image.getSource(), filter);

Image resultImage = Toolkit.getDefaultToolkit().createImage(
    producer);
ImageIO.write(resultImage, "jpg", 
    new File("C:/Graphics/src/name7.jpg"));  //not allowing me  

//这是行显示错误为:

The method write(RenderedImage, String, File) in the type ImageIO is not 
    applicable for the arguments (Image, String, File)
4

1 回答 1

0

请参阅BufferedImage.html#getSubimage(x,y,,w,h)子图像。

要获得BufferedImage,请使用ImageIO.read(File/InputStream/URL)


The method write(RenderedImage, String, File) in the type ImageIO is not 
    applicable for the arguments (Image, String, File)

image显然声明为,将Image其更改为:

BufferedImage image = ImageIO.read(new File("C:/Graphics/src/name2.jpg"));       
于 2012-04-12T14:57:24.490 回答