Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * reduces the size of the image
- * param image bitmap received from camera
- * @param maxSize
- * @return
- */
- public Bitmap getResizedBitmap(Bitmap image, int maxSize) {
- int width = image.getWidth();
- int height = image.getHeight();
- float bitmapRatio = (float)width / (float) height;
- if (bitmapRatio > 0) {
- width = maxSize;
- height = (int) (width / bitmapRatio);
- } else {
- height = maxSize;
- width = (int) (height * bitmapRatio);
- }
- return Bitmap.createScaledBitmap(image, width, height, true);
- }
- Bitmap scaledImage = getResizedBitmap(photo, 200); //here 200 is maxsize
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement