2016-08-11 37 views
0

我想旋轉並將旋轉位圖保存到特定文件路徑而不壓縮它。在我使用下面的代碼進行旋轉之前,將其壓縮並存儲到特定的文件中。現在我不想壓縮我的位圖。請建議我旋轉並將位圖保存到指定的路徑。如何將旋轉位圖寫入特定文件而不壓縮android

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) { 
     e.printStackTrace(); 
    } 
} 

當我打電話給這種方法。我會將我的圖像路徑傳遞給此方法。

回答

1

PNG是無損的,所以你可以使用Bitmap.CompressFormat.PNG

Compresion

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 
+0

@Sangeetha仍然有問題? –

+0

亞工作感謝你。 – Sangeetha

+0

請勾選標記,然後投票,然後快樂的編碼:) –

相關問題