diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-01-24 15:47:53 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-01-27 18:45:16 +0100 |
commit | 4d358260140c9d52103cc95631a8519b969bc408 (patch) | |
tree | daf17b610189a824eab34e4055b9bc0ebf585375 /platform/android/src/image.cpp | |
parent | 14d5c336d72f3af54e3f72295e901591e219b5a9 (diff) | |
download | qtlocation-mapboxgl-4d358260140c9d52103cc95631a8519b969bc408.tar.gz |
[android] use native image encoding and decoding
Diffstat (limited to 'platform/android/src/image.cpp')
-rw-r--r-- | platform/android/src/image.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/platform/android/src/image.cpp b/platform/android/src/image.cpp new file mode 100644 index 0000000000..2a33944b18 --- /dev/null +++ b/platform/android/src/image.cpp @@ -0,0 +1,22 @@ +#include <mbgl/util/image.hpp> +#include <mbgl/util/string.hpp> + +#include <string> + +#include "attach_env.hpp" +#include "bitmap_factory.hpp" + +namespace mbgl { + +PremultipliedImage decodeImage(const std::string& string) { + auto env{ android::AttachEnv() }; + + auto array = jni::Array<jni::jbyte>::New(*env, string.size()); + jni::SetArrayRegion(*env, *array, 0, string.size(), + reinterpret_cast<const signed char*>(string.data())); + + auto bitmap = android::BitmapFactory::DecodeByteArray(*env, array, 0, string.size()); + return android::Bitmap::GetImage(*env, bitmap); +} + +} // namespace mbgl |