This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] - add logo resize to MapSnapshotter
- Loading branch information
Showing
2 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
...oid/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnaphotUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters