Sangeetha Sangeetha - 8 months ago 70
Android Question

How to write rotated bitmap into specific file without compress android

I want to rotate and save rotated bitmap to specific file path without compress it. Before i have used the below code for rotate, compress and store it to a specific file. Now i dnt want to compress my bitmap. Please suggest me an idea to rotate and save the bitmap into specified path.

public static void compressToStandard(String file) {

BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file, bmOptions);

bmOptions.inJustDecodeBounds = false;
bmOptions.inSampleSize = getInSampleSize(bmOptions);

try {
Bitmap bitmap = BitmapFactory.decodeFile(file, bmOptions);
bitmap = ExifUtils.rotateBitmap(file, bitmap);
Log.i("ImageUtils", "compressed bitmap size:" + bitmap.getWidth() + "x" + bitmap.getHeight());
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, new FileOutputStream(file));
} catch (Exception e) {

when i call this method. I will pass my image path to this method.


PNG is lossless so you can use Bitmap.CompressFormat.PNG


    Hint to the compressor, 0-100. 0 meaning compress for 
    small size, 100 meaning compress for max quality. Some
    formats, like PNG which is lossless, will ignore the
    quality setting