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

Method MakeFrom

src/platform/web/NativeCodec.cpp:62–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62std::shared_ptr<ImageCodec> ImageCodec::MakeFrom(NativeImageRef nativeImage) {
63 if (!nativeImage.as<bool>()) {
64 return nullptr;
65 }
66 auto size = val::module_property("tgfx").call<val>("getSourceSize", nativeImage);
67 auto width = size["width"].as<int>();
68 auto height = size["height"].as<int>();
69 if (width < 1 || height < 1) {
70 return nullptr;
71 }
72 return std::shared_ptr<NativeCodec>(new NativeCodec(width, height, std::move(nativeImage)));
73}
74
75NativeCodec::NativeCodec(int width, int height, std::shared_ptr<Data> imageBytes)
76 : ImageCodec(width, height), imageBytes(std::move(imageBytes)) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected