Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. I'm trying to convert byte[] into image. The byte[] comes from JSON and it's in this format:
  2.  
  3. I'm using the following code convert byte[] to bitmap image.
  4.  
  5. String encodedString="255,216,255,224,0,16,74,70,73,70,0,1,1,0,0,1,0,1,0....";
  6. byte[] encodeByte = encodedString.getBytes();
  7. System.out.println("encodeByte : "+encodeByte);
  8. System.out.println("encodeByte.length : "+encodeByte.length);
  9. Bitmap photo=BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
  10. System.out.println("Bitmap photo : "+photo);
  11. btnImg.setImageBitmap(photo);
  12.  
  13. I'm getting the following error in Logcat:
  14.  
  15. 10-31 00:20:57.210: I/System.out(1315): encodeByte : [B@b3d249d8
  16. 10-31 00:20:57.210: I/System.out(1315): encodeByte.length : 18320
  17. 10-31 00:20:57.220: D/skia(1315): --- SkImageDecoder::Factory returned null
  18. 10-31 00:20:57.220: I/System.out(1315): Bitmap photo : null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement