| Index: chrome/android/java/src/org/chromium/chrome/browser/photo_picker/BitmapUtils.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/BitmapUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/BitmapUtils.java
|
| index ddad8aa24789fdb7444e6fd352f9feaf99e4ae08..f1e7620d5f6e8831318ce84ab5259f688385d5dc 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/BitmapUtils.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/BitmapUtils.java
|
| @@ -107,4 +107,20 @@ class BitmapUtils {
|
| if (height > size) y = (height - size) / 2;
|
| return Bitmap.createBitmap(bitmap, x, y, size, size);
|
| }
|
| +
|
| + /**
|
| + * Scales a |bitmap| to a certain size.
|
| + * @param bitmap The bitmap to scale.
|
| + * @param scaleMaxSize What to scale it to.
|
| + * @param filter True if the source should be filtered.
|
| + * @return The resulting scaled bitmap.
|
| + */
|
| + public static Bitmap scale(Bitmap bitmap, float scaleMaxSize, boolean filter) {
|
| + float ratio = Math.min((float) scaleMaxSize / bitmap.getWidth(),
|
| + (float) scaleMaxSize / bitmap.getHeight());
|
| + int height = Math.round(ratio * bitmap.getHeight());
|
| + int width = Math.round(ratio * bitmap.getWidth());
|
| +
|
| + return Bitmap.createScaledBitmap(bitmap, width, height, filter);
|
| + }
|
| }
|
|
|