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

Function CopyDataFromUint8Array

src/platform/web/NativeCodec.cpp:30–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28namespace tgfx {
29
30std::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
49std::shared_ptr<ImageCodec> ImageCodec::MakeNativeCodec(const std::string&) {
50 return nullptr;

Callers 1

onReadPixelsMethod · 0.85

Calls 3

isEmptyMethod · 0.45
dataMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected