Tuesday, 18 June 2019

How to Bitmap Compress reduce size and Compress format

Here you can reduce Bitmap Size and Compress in specific file format



//Bitmap bitmap = your Bitmap

File file = new File(Environment.getExternalStorageDirectory(),"test1.jpg");
String filename = file.getAbsolutePath();
try (FileOutputStream out = new FileOutputStream(filename)) {
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);

// bmp is your Bitmap instance
// PNG format using for compression factor (100) is ignored

} catch (IOException e)
{
e.printStackTrace();
}


No comments:

Post a Comment

Comments

Snackbar in Kotlin

How to show snackbar in place of toast message , below is the code for showing snackbar in kotlin. Below code is put in Utils.kt  (common fi...