| 242 | } |
| 243 | |
| 244 | std::shared_ptr<ImageCodec> ImageCodec::MakeFrom(NativeImageRef nativeImage) { |
| 245 | JNIEnvironment environment; |
| 246 | auto env = environment.current(); |
| 247 | if (env == nullptr) { |
| 248 | return nullptr; |
| 249 | } |
| 250 | if (BitmapFactoryOptionsClass.get() == nullptr) { |
| 251 | LOGE("Could not run NativeCodec.MakeNativeCodec(), BitmapFactoryOptionsClass is not found!"); |
| 252 | return nullptr; |
| 253 | } |
| 254 | auto info = AndroidBitmap::GetInfo(env, nativeImage); |
| 255 | if (info.isEmpty()) { |
| 256 | return nullptr; |
| 257 | } |
| 258 | auto image = std::shared_ptr<NativeCodec>( |
| 259 | new NativeCodec(info.width(), info.height(), Orientation::TopLeft)); |
| 260 | image->nativeImage = nativeImage; |
| 261 | return image; |
| 262 | } |
| 263 | |
| 264 | static jobject ConvertHardwareBitmap(JNIEnv* env, jobject bitmap) { |
| 265 | // The AndroidBitmapInfo does not contain the ANDROID_BITMAP_FLAGS_IS_HARDWARE flag in the old |