[android] use native image encoding and decoding

This commit is contained in:
Konstantin Käfer
2017-01-24 15:47:53 +01:00
parent 14d5c336d7
commit 4d35826014
10 changed files with 278 additions and 59 deletions

View File

@@ -18,6 +18,8 @@
#include <mbgl/util/constants.hpp>
#include <mbgl/util/image.hpp>
#include "bitmap.hpp"
namespace mbgl {
namespace android {
@@ -172,14 +174,10 @@ void NativeMapView::render() {
// take snapshot
auto image = getContext().readFramebuffer<mbgl::PremultipliedImage>(getFramebufferSize());
// encode and convert to jbytes
std::string string = encodePNG(image);
jbyteArray arr = env->NewByteArray(string.length());
env->SetByteArrayRegion(arr,0,string.length(),(jbyte*)string.c_str());
auto bitmap = Bitmap::CreateBitmap(*env, std::move(image));
// invoke Mapview#OnSnapshotReady
env->CallVoidMethod(obj, onSnapshotReadyId, arr);
env->CallVoidMethod(obj, onSnapshotReadyId, jni::Unwrap(*bitmap));
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
}