MCPcopy Create free account
hub / github.com/Tencent/tgfx / GetInfo

Method GetInfo

src/platform/android/AndroidBitmap.cpp:28–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26static constexpr int BITMAP_FORMAT_RGBA_1010102 = 10;
27
28ImageInfo AndroidBitmap::GetInfo(JNIEnv* env, jobject bitmap) {
29 if (env == nullptr || bitmap == nullptr) {
30 return {};
31 }
32 AndroidBitmapInfo bitmapInfo = {};
33 if (AndroidBitmap_getInfo(env, bitmap, &bitmapInfo) != 0) {
34 env->ExceptionClear();
35 return {};
36 }
37 AlphaType alphaType = (bitmapInfo.flags & BITMAP_FLAGS_ALPHA_UNPREMUL)
38 ? AlphaType::Unpremultiplied
39 : AlphaType::Premultiplied;
40 ColorType colorType;
41 switch (bitmapInfo.format) {
42 case ANDROID_BITMAP_FORMAT_RGBA_8888:
43 colorType = ColorType::RGBA_8888;
44 break;
45 case ANDROID_BITMAP_FORMAT_A_8:
46 colorType = ColorType::ALPHA_8;
47 break;
48 case ANDROID_BITMAP_FORMAT_RGB_565:
49 colorType = ColorType::RGB_565;
50 break;
51 case BITMAP_FORMAT_RGBA_F16:
52 colorType = ColorType::RGBA_F16;
53 break;
54 case BITMAP_FORMAT_RGBA_1010102:
55 colorType = ColorType::RGBA_1010102;
56 break;
57 default:
58 colorType = ColorType::Unknown;
59 break;
60 }
61 return ImageInfo::Make(static_cast<int>(bitmapInfo.width), static_cast<int>(bitmapInfo.height),
62 colorType, alphaType, bitmapInfo.stride);
63}
64
65HardwareBufferRef AndroidBitmap::GetHardwareBuffer(JNIEnv* env, jobject bitmap) {
66 static const auto fromBitmap = AHardwareBufferFunctions::Get()->fromBitmap;

Callers

nothing calls this directly

Calls 1

MakeFunction · 0.85

Tested by

no test coverage detected