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

Method GetPixelmapInfo

src/platform/ohos/NativeCodec.cpp:170–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170ImageInfo NativeCodec::GetPixelmapInfo(OH_PixelmapNative* pixelmap) {
171 OH_Pixelmap_ImageInfo* currentInfo = nullptr;
172 auto errorCode = OH_PixelmapImageInfo_Create(&currentInfo);
173 if (errorCode != Image_ErrorCode::IMAGE_SUCCESS) {
174 LOGE("NativeCodec::readPixels() Failed to Decode Image");
175 return {};
176 }
177 OH_PixelmapNative_GetImageInfo(pixelmap, currentInfo);
178
179 int32_t pixelFormat = 0;
180 OH_PixelmapImageInfo_GetPixelFormat(currentInfo, &pixelFormat);
181 ColorType colorType = OHOSImageInfo::ToTGFXColorType(pixelFormat);
182
183 int32_t alpha = 0;
184 OH_PixelmapImageInfo_GetAlphaType(currentInfo, &alpha);
185 AlphaType alphaType = OHOSImageInfo::ToTGFXAlphaType(alpha);
186 if (alphaType == AlphaType::Unknown) {
187 // Default is Premultiplied
188 alphaType = AlphaType::Premultiplied;
189 }
190 uint32_t width = 0;
191 OH_PixelmapImageInfo_GetWidth(currentInfo, &width);
192 uint32_t height = 0;
193 OH_PixelmapImageInfo_GetHeight(currentInfo, &height);
194 uint32_t rowBytes = 0;
195 OH_PixelmapImageInfo_GetRowStride(currentInfo, &rowBytes);
196 OH_PixelmapImageInfo_Release(currentInfo);
197 return ImageInfo::Make((int)width, (int)height, colorType, alphaType, rowBytes);
198}
199
200OH_ImageSourceNative* NativeCodec::CreateImageSource() const {
201 OH_ImageSourceNative* imageSource = nullptr;

Callers

nothing calls this directly

Calls 1

MakeFunction · 0.85

Tested by

no test coverage detected