| 86 | } |
| 87 | |
| 88 | bool NativeCodec::onReadPixels(ColorType colorType, AlphaType alphaType, size_t dstRowBytes, |
| 89 | void* dstPixels) const { |
| 90 | if (dstPixels == nullptr) { |
| 91 | return false; |
| 92 | } |
| 93 | |
| 94 | auto data = val::module_property("tgfx").call<val>( |
| 95 | "readImagePixels", val::module_property("module"), nativeImage, width(), height()); |
| 96 | auto imageData = CopyDataFromUint8Array(data); |
| 97 | if (imageData == nullptr) { |
| 98 | return false; |
| 99 | } |
| 100 | auto info = ImageInfo::Make(width(), height(), ColorType::RGBA_8888, AlphaType::Unpremultiplied); |
| 101 | auto dstInfo = ImageInfo::Make(width(), height(), colorType, alphaType, dstRowBytes); |
| 102 | Pixmap pixmap(info, imageData->data()); |
| 103 | auto result = pixmap.readPixels(dstInfo, dstPixels); |
| 104 | return result; |
| 105 | } |
| 106 | |
| 107 | std::shared_ptr<ImageBuffer> NativeCodec::onMakeBuffer(bool) const { |
| 108 | auto image = nativeImage; |
nothing calls this directly
no test coverage detected