Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. /**
  2. * reduces the size of the image
  3. * param image bitmap received from camera
  4. * @param maxSize
  5. * @return
  6. */
  7. public Bitmap getResizedBitmap(Bitmap image, int maxSize) {
  8. int width = image.getWidth();
  9. int height = image.getHeight();
  10.  
  11. float bitmapRatio = (float)width / (float) height;
  12. if (bitmapRatio > 0) {
  13. width = maxSize;
  14. height = (int) (width / bitmapRatio);
  15. } else {
  16. height = maxSize;
  17. width = (int) (height * bitmapRatio);
  18. }
  19. return Bitmap.createScaledBitmap(image, width, height, true);
  20. }
  21.  
  22. Bitmap scaledImage = getResizedBitmap(photo, 200); //here 200 is maxsize
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement