bitmap.compress(Bitmap.CompressFormat.PNG, 0, fOut) making image size bigger than original bitmap.compress(Bitmap.CompressFormat.PNG, 0, fOut) making image size bigger than original android android

bitmap.compress(Bitmap.CompressFormat.PNG, 0, fOut) making image size bigger than original


The images taken with the camera are most likely stored in the jpg-format, which is lossy, but is relatively good for images with lots of colors (such as photographs).

When you compress the bitmap using your method you save it as a png. The png compression is lossless, but can achieve pretty small filesizes when there are few colors (such as in certain logotypes or other graphics). When the amount of colors and complexity in a png-file increases, so will the file size (this is why the camera saves a jpg - the quality/filesize ratio is much better than png for most photographs).

So, if you want to decrease the filesize of the photographs, use jpg compression and experiment with the quality-parameter. You might also want to decrease the resolution of the images, since this will save lots of space (a file with 50% resolution will be approx. 25% in data-size).


it work fine on my app

    public static String makeScreen(View view) throws Exception {    String filename = "file.png";    view.setDrawingCacheEnabled(true);    view.buildDrawingCache();    Bitmap b = view.getDrawingCache();    FileOutputStream file = null;    try {        file = new FileOutputStream(Environment.getExternalStorageDirectory().toString() + "folder/" + filename);        if (file != null) {            b.compress(Bitmap.CompressFormat.PNG, 98, file);            file.close();        }        view.destroyDrawingCache();    } catch (Exception e) { view.destroyDrawingCache(); }}