summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/callcomposer/util/BitmapResizer.java
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-06-22 09:39:08 -0700
committerEric Erfanian <erfanian@google.com>2017-06-22 17:23:58 +0000
commit842a9777de13bebb1c82f9d57222c52f9ddec558 (patch)
tree742285fa641f62ba0b358a65a452f4f65db04ce2 /java/com/android/dialer/callcomposer/util/BitmapResizer.java
parenta8a71b12c67ca852382e94d5e6d5d04430529902 (diff)
Update AOSP Dialer source from internal google3 repository at
cl/159771812. Test: make, treehugger This CL updates the AOSP Dialer source with all the changes that have gone into the private google3 repository. This includes all the changes from cl/159428781 (6/19/2017) to cl/159771812 (6/22/2017). These changes track the dialer V11 release. This goal of these drops is to keep the AOSP source in sync with the internal google3 repository. Currently these sync are done by hand with very minor modifications to the internal source code. See the Android.mk file for list of modifications. Merged-In: I39aba7e972bac6e5864e70ed693849d90ecd7e08 Change-Id: Ia87877f7ae67c5b56078477b8b08082de1355315
Diffstat (limited to 'java/com/android/dialer/callcomposer/util/BitmapResizer.java')
-rw-r--r--java/com/android/dialer/callcomposer/util/BitmapResizer.java35
1 files changed, 20 insertions, 15 deletions
diff --git a/java/com/android/dialer/callcomposer/util/BitmapResizer.java b/java/com/android/dialer/callcomposer/util/BitmapResizer.java
index 658462def..84ada51d8 100644
--- a/java/com/android/dialer/callcomposer/util/BitmapResizer.java
+++ b/java/com/android/dialer/callcomposer/util/BitmapResizer.java
@@ -17,6 +17,7 @@
package com.android.dialer.callcomposer.util;
import android.graphics.Bitmap;
+import android.graphics.Matrix;
import android.support.annotation.VisibleForTesting;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
@@ -28,40 +29,44 @@ public final class BitmapResizer {
/**
* Returns a bitmap that is a resized version of the parameter image. The image will only be
* resized down and sized to be appropriate for an enriched call.
+ *
+ * @param image to be resized
+ * @param rotation degrees to rotate the image clockwise
+ * @return resized image
*/
- public static Bitmap resizeForEnrichedCalling(Bitmap image) {
+ public static Bitmap resizeForEnrichedCalling(Bitmap image, int rotation) {
Assert.isWorkerThread();
int width = image.getWidth();
int height = image.getHeight();
+ Matrix matrix = new Matrix();
+ matrix.postRotate(rotation);
+
LogUtil.i(
"BitmapResizer.resizeForEnrichedCalling", "starting height: %d, width: %d", height, width);
if (width <= MAX_OUTPUT_RESOLUTION && height <= MAX_OUTPUT_RESOLUTION) {
LogUtil.i("BitmapResizer.resizeForEnrichedCalling", "no resizing needed");
- return image;
+ return Bitmap.createBitmap(image, 0, 0, width, height, matrix, true);
}
+ float ratio = 1;
if (width > height) {
// landscape
- float ratio = width / (float) MAX_OUTPUT_RESOLUTION;
- width = MAX_OUTPUT_RESOLUTION;
- height = (int) (height / ratio);
- } else if (height > width) {
- // portrait
- float ratio = height / (float) MAX_OUTPUT_RESOLUTION;
- height = MAX_OUTPUT_RESOLUTION;
- width = (int) (width / ratio);
+ ratio = MAX_OUTPUT_RESOLUTION / (float) width;
} else {
- // square
- height = MAX_OUTPUT_RESOLUTION;
- width = MAX_OUTPUT_RESOLUTION;
+ // portrait & square
+ ratio = MAX_OUTPUT_RESOLUTION / (float) height;
}
LogUtil.i(
- "BitmapResizer.resizeForEnrichedCalling", "ending height: %d, width: %d", height, width);
+ "BitmapResizer.resizeForEnrichedCalling",
+ "ending height: %f, width: %f",
+ height * ratio,
+ width * ratio);
- return Bitmap.createScaledBitmap(image, width, height, true);
+ matrix.postScale(ratio, ratio);
+ return Bitmap.createBitmap(image, 0, 0, width, height, matrix, true);
}
}