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

Find Hours Diffrence in Kotlin

  In Kotlin, determining the difference in hours between two timestamps is a common task, especially in scenarios involving time-based calcu...