I have the following code snippet to convert an image to a byte array.
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(image, "png", baos); baos.flush(); byte[] imageBytes = baos.toByteArray(); baos.close();
The problem I am facing is that the image size is about 2.65 MB. However, imageBytes.length gives me a value of more than 5.5 MB. Can anyone tell me where I am going wrong?
source share