Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. m_galleryIntent = new Intent();
  2. m_galleryIntent.setType("image/*");
  3. m_galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
  4.  
  5. m_profileButton.setOnClickListener(new OnClickListener()
  6. {
  7. public void onClick(View v)
  8. {
  9. startActivityForResult(Intent.createChooser(m_galleryIntent, "Select Picture"),1);
  10. }
  11. });
  12.  
  13. Bitmap yourBitmap;
  14. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  15. yourBitmap.compress(Bitmap.CompressFormat.PNG, 100, bos);
  16. byte[] bArray = bos.toByteArray();
  17.  
  18. public static byte[] getBytesFromBitmap(Bitmap bitmap) {
  19. if (bitmap!=null) {
  20. ByteArrayOutputStream stream = new ByteArrayOutputStream();
  21. bitmap.compress(Bitmap.CompressFormat.JPEG, 70, stream);
  22. return stream.toByteArray();
  23. }
  24. return null;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement