I noticed that after I converted my jpeg file into a bitmap the size drops almost by half, is this normal? I doing something like this:
bmp1 = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()
+ "/Test/test" + System.currentTimeMillis()
+ ".jpg");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp1.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] byteArray = st开发者_如何转开发ream.toByteArray();
System.out.println(byteArray.length);
Your code is decoding a jpeg into a bitmap and then re-compressing it into a jpeg again. The re-compression is likely to be reducing the file size, at the cost of also reducing the quality of the image.
Jpeg compression (even at quality 100) is not lossless.
精彩评论