I am trying to compress a bitmap, but getting a null pointer exception..the logcat is displaying uncaught exception
Bitmap bitmap = BitmapFactory.decodeByteArray(imageAsBytes , 0, imageAsBytes .length);
Bitmap bPNGcompress =codec(bitmap, Bitmap.CompressFormat.PNG, 0);
Bitmap scaled = bPNGcompress.createScaledBitmap( bPNGcompress, 100, 100, true );
method implementation
private static Bitmap codec(Bitmap map, Bitmap.CompressFormat format,
int quality) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
map.compress(format, quality, os);
try {
os.flush();
os.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
byte[] array = os.toByteArray();
return BitmapFactory.decodeByteArray(array, 0, array.length);
}