Hi I want to convert a Bitmap to byte[] i did this :
byte[] imageInByte;
Uri uri = data.getData();
bitmap = null;
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
} catch (IOException e) {
e.printStackTrace();
}
int size = bitmap.getRowBytes() * bitmap.getHeight();
ByteBuffer byteBuffer = ByteBuffer.allocate(size);
bitmap.copyPixelsToBuffer(byteBuffer);
imageInByte = byteBuffer.array();
Next I want to convert this byte[] to Bitmap and I did this :
Bitmap bmp = BitmapFactory.decodeByteArray(imageInByte, 0, imageInByte.length);
And when I what check a bmp.getWidth();
and show in Toast:
Toast.makeText(this,bmp.getWidth()+"",Toast.LENGTH_SHORT).show();
I have nullpointer please help me