I\'m trying to save an image in bmp format, but it doesn\'t create any file. If I use \"png\" instead, everything works fine. Any ideas?
//This works fine:
I
didn't try but I think the format should be "BMP" and not "bmp" actually. Please try with
ImageIO.write(bi, "BMP", new File("D:\\MyImage.bmp"));
and see what happens.
We can't see how your bi is build.
BufferedImage bufferedImage = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
Is the encodingType is set properly ?
I think your bi is corrupted, that's work perfectly for me.
BufferedImage bi = new BufferedImage(50,50,BufferedImage.TYPE_INT_RGB);
Graphics gd = bi.getGraphics();
gd.drawRect(0, 0, 10, 10);
try {
ImageIO.write(bi, "BMP", new File("C:\\test.bmp"));
ImageIO.write(bi, "PNG", new File("C:\\test.png"));
} catch (IOException e) {
System.out.println("error "+e.getMessage());
}