我创建了新的BufferedImage gimage(灰色图像)和一个名为Gimage的Image。在那里我使用方法GrayFilter,然后我在我的BufferedImage上绘制了Image,但我得到了空输出图像。下面的代码有什么问题?
BufferedImage gimage = new BufferedImage(img.getWidth(),img.getHeight(),BufferedImage.TYPE_BYTE_BINARY);
ImageFilter filter = new GrayFilter(true,50);
ImageProducer producer = new FilteredImageSource(img.getSource(),filter);
Image Gimage = Toolkit.getDefaultToolkit().createImage(producer);
gimage.getGraphics().drawImage(Gimage, 0, 0 , null);
ImageIO.write(gimage, "png", new File("out.png"));