Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. //proceso de transformar la imagen BitMap en un String:
  2. //android:src="c:logo.png"
  3. Resources r = this.getResources();
  4. Bitmap bm = BitmapFactory.decodeResource(r, R.drawable.logo);
  5. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  6. bm.compress(Bitmap.CompressFormat.PNG, 100, baos); //bm is the bitmap object
  7. byte[] b = baos.toByteArray();
  8. //String encodedImage = Base64.encode(b, Base64.DEFAULT);
  9. encodedImage = Base64.encodeBytes(b);
  10.  
  11. byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);
  12. Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
  13.  
  14. byte[] decodedString = Base64.decode(encodedImage, Base64.URL_SAFE);
  15. Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement