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

Method CreateImageSource

src/platform/ohos/NativeCodec.cpp:200–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200OH_ImageSourceNative* NativeCodec::CreateImageSource() const {
201 OH_ImageSourceNative* imageSource = nullptr;
202 if (imagePath.empty()) {
203 auto errorCode = OH_ImageSourceNative_CreateFromData(const_cast<uint8_t*>(imageBytes->bytes()),
204 imageBytes->size(), &imageSource);
205 if (errorCode != IMAGE_SUCCESS) {
206 LOGE("NativeCodec::CreateImageSource() Failed to CreateFromData");
207 return nullptr;
208 }
209 } else {
210 auto errorCode =
211 OH_ImageSourceNative_CreateFromUri(const_cast<char*>(imagePath.c_str()),
212 static_cast<size_t>(imagePath.length()), &imageSource);
213 if (errorCode != IMAGE_SUCCESS) {
214 LOGE("NativeCodec::CreateImageSource() Failed to CreateFromUri: %s", imagePath.c_str());
215 return nullptr;
216 }
217 }
218 return imageSource;
219}
220
221} // namespace tgfx

Callers

nothing calls this directly

Calls 5

c_strMethod · 0.80
lengthMethod · 0.80
emptyMethod · 0.45
bytesMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected