| 28 | namespace tgfx { |
| 29 | |
| 30 | std::shared_ptr<Data> CopyDataFromUint8Array(const val& emscriptenData) { |
| 31 | if (!emscriptenData.as<bool>()) { |
| 32 | return nullptr; |
| 33 | } |
| 34 | auto length = emscriptenData["length"].as<size_t>(); |
| 35 | if (length == 0) { |
| 36 | return nullptr; |
| 37 | } |
| 38 | Buffer imageBuffer(length); |
| 39 | if (imageBuffer.isEmpty()) { |
| 40 | return nullptr; |
| 41 | } |
| 42 | auto memory = val::module_property("HEAPU8")["buffer"]; |
| 43 | auto memoryView = val::global("Uint8Array") |
| 44 | .new_(memory, reinterpret_cast<uintptr_t>(imageBuffer.data()), length); |
| 45 | memoryView.call<void>("set", emscriptenData); |
| 46 | return imageBuffer.release(); |
| 47 | } |
| 48 | |
| 49 | std::shared_ptr<ImageCodec> ImageCodec::MakeNativeCodec(const std::string&) { |
| 50 | return nullptr; |
no test coverage detected