
Originally Posted by
svishwa11
Hi,
Trial 1. In this case, decodeByteArray returns null.
Sender: Image File to Byte Array
String filepath = "/sdcard/";
File imagefile = new File(filepath + "icon.png");
FileInputStream fis = new FileInputStream(imagefile);
Bitmap bi = BitmapFactory.decodeStream(fis);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] data = baos.toByteArray();
...
I dont understand why decodebytearray returns null.
Trial 2: Normal fileoutputstream avoiding bitmap totally.
..
This writes the bytes but not able to view/open the written file. Looks like the file is corrupted. I guess this is not the way for image files.
Bookmarks