1

I am encountering a problem converting BufferedImage to bitmap. When doing this conversion the file size is always 0. However, when I make BufferedImage for png, the conversion is successful.

This is the code for converting to png. This one works.

bimg =ImageIO.read(new File("src/IMPRESSORA_ZEBRA/2ºAno.png"));
baos= new ByteArrayOutputStream();
System.out.println(bimg.getWidth() +" X "+bimg.getHeight());
ImageIO.write(bimg,"png", baos);

This is the code for conversion to Bitmap.

bimg =ImageIO.read(new File("src/IMPRESSORA_ZEBRA/2ºAno.png"));
baos= new ByteArrayOutputStream();
System.out.println(bimg.getWidth() +" X "+bimg.getHeight());
ImageIO.write(bimg,"bmp", baos));

It simply results in a null file. Even when I try to save to a file, nothing happens and I don't get any error messages. Just nothing happens.

Well, I think I made the idea clear. sorry for my english. If anyone has any solution to this problem, help me.

Thank you in advance. Thanks.

0 Answers0