开发者

Android JPEG to Bitmap = reduction in size

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜