MCPcopy Create free account
hub / github.com/Tencent/libpag / isEmptyBitmapFrame

Method isEmptyBitmapFrame

src/base/BitmapSequence.cpp:47–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47bool BitmapSequence::isEmptyBitmapFrame(size_t frameIndex) {
48 // There was a bug in PAGExporter that causes an empty frame being exported as 1x1 frame, so we
49 // need to identify this kind of empty frame here.
50 if (frameIndex >= frames.size()) {
51 return false;
52 }
53 auto frame = frames[frameIndex];
54 for (auto bitmap : frame->bitmaps) {
55 if (bitmap->x != 0 || bitmap->y != 0) {
56 return false;
57 }
58 if (bitmap->fileBytes->length() > 150) {
59 return false;
60 }
61
62 int width = 0;
63 int height = 0;
64 if (!WebPGetInfo(bitmap->fileBytes->data(), bitmap->fileBytes->length(), &width, &height)) {
65 LOGE("Get webP size fail.");
66 }
67 if (width > 1 || height > 1) {
68 return false;
69 }
70 }
71 return true;
72}
73
74bool BitmapSequence::verify() const {
75 if (!Sequence::verify() || frames.empty()) {

Callers 1

Calls 4

WebPGetInfoFunction · 0.85
sizeMethod · 0.80
lengthMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected