NativeMapView.addImage without copying into Java

This commit is contained in:
Benjamin Jaeger
2018-01-23 15:33:29 -05:00
committed by Tobrun
parent f3b3259906
commit 0b27909b8b
3 changed files with 6 additions and 23 deletions

View File

@@ -758,20 +758,11 @@ final class NativeMapView {
return;
}
// Check/correct config
if (image.getConfig() != Bitmap.Config.ARGB_8888) {
image = image.copy(Bitmap.Config.ARGB_8888, false);
}
// Get pixels
ByteBuffer buffer = ByteBuffer.allocate(image.getByteCount());
image.copyPixelsToBuffer(buffer);
// Determine pixel ratio
float density = image.getDensity() == Bitmap.DENSITY_NONE ? Bitmap.DENSITY_NONE : image.getDensity();
float pixelRatio = density / DisplayMetrics.DENSITY_DEFAULT;
nativeAddImage(name, image.getWidth(), image.getHeight(), pixelRatio, buffer.array());
nativeAddImage(name, image, pixelRatio);
}
public void addImages(@NonNull HashMap<String, Bitmap> bitmapHashMap) {
@@ -1032,8 +1023,7 @@ final class NativeMapView {
private native void nativeRemoveSource(Source source, long sourcePtr);
private native void nativeAddImage(String name, int width, int height, float pixelRatio,
byte[] array);
private native void nativeAddImage(String name, Bitmap bitmap, float pixelRatio);
private native void nativeAddImages(Image[] images);