I have a strange issue with ByteArrayOutputStream. I am trying to input an image and convert it to an array of bytes. The image is 270 x 480 pixels. However if I set data to the byte array and output data.length I get 21195 however 270 x 480 = 129600. Shouldn't they be the same? What am I doing wrong here?
BufferedImage originalImage =
ImageIO.read(new File("C:\\Users\\use\\Pictures\\mypic.jpg"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write( originalImage, "jpg", baos );
baos.flush();
data = baos.toByteArray();
baos.close();
thanks,