summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnaphotUtil.java
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2017-10-29 08:01:10 -0700
committerTobrun <tobrun@mapbox.com>2017-11-01 14:56:37 -0700
commita5ff277ed98dfc7a21ef92f99567ee5a682a2210 (patch)
treec684889d4001910114a94bbc6d30a9c0b91843db /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnaphotUtil.java
parentcb7f6dfaec2f90a81d588c2458e01d2a191f9ba1 (diff)
downloadqtlocation-mapboxgl-a5ff277ed98dfc7a21ef92f99567ee5a682a2210.tar.gz
[android] - add logo resize to MapSnapshotter
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnaphotUtil.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnaphotUtil.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnaphotUtil.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnaphotUtil.java
new file mode 100644
index 0000000000..da86dc51fb
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnaphotUtil.java
@@ -0,0 +1,29 @@
+package com.mapbox.mapboxsdk.snapshotter;
+
+import android.graphics.BitmapFactory;
+
+class MapSnaphotUtil {
+
+ static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
+ // Raw height and width of image
+ final int height = options.outHeight;
+ final int width = options.outWidth;
+ int inSampleSize = 1;
+
+ if (height > reqHeight || width > reqWidth) {
+
+ final int halfHeight = height / 2;
+ final int halfWidth = width / 2;
+
+ // Calculate the largest inSampleSize value that is a power of 2 and keeps both
+ // height and width larger than the requested height and width.
+ while ((halfHeight / inSampleSize) >= reqHeight
+ && (halfWidth / inSampleSize) >= reqWidth) {
+ inSampleSize *= 2;
+ }
+ }
+ return inSampleSize;
+ }
+
+
+}