开发者

Android JPEG to Bitmap = reduction in size

开发者 https://www.devze.com 2023-03-20 17:18 出处:网络
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:

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

精彩评论

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