| 60 | } |
| 61 | |
| 62 | std::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 | |
| 75 | NativeCodec::NativeCodec(int width, int height, std::shared_ptr<Data> imageBytes) |
| 76 | : ImageCodec(width, height), imageBytes(std::move(imageBytes)) { |
nothing calls this directly
no outgoing calls
no test coverage detected