0

我试图转换一个bmp:

File file = new File(source.getText());

    try {
        BufferedImage i = ImageIO.read(file);
        if (i != null) {

            BufferedImage convertedImg = new BufferedImage(i.getWidth(), i.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
            boolean drawImage = convertedImg.getGraphics().drawImage(i, 0, 0, null);

                File f = new File(output.getText().concat(File.separatorChar + "out.bmp"));
                boolean write = ImageIO.write(convertedImg, "BMP", f);
        } else {
            //...
        }
    }catch (Exception e) {
            e.printStackTrace();
    }

但它没有正确写入图像。当我打开bmp它说文件是空的?我究竟做错了什么?

编辑:写返回假。

4

0 回答 0