diff --git a/src/wasm/thorvgwasm.cpp b/src/wasm/thorvgwasm.cpp index d0f01866..3a59a204 100644 --- a/src/wasm/thorvgwasm.cpp +++ b/src/wasm/thorvgwasm.cpp @@ -48,7 +48,7 @@ public: return defaultData; } - bool load(string data, int width, int height) + bool load(string data, string mimetype, int width, int height) { mErrorMsg = "None"; @@ -66,7 +66,7 @@ public: mSwCanvas->clear(); if (data.empty()) data = defaultData; - if (mPicture->load(data.c_str(), data.size()) != Result::Success) { + if (mPicture->load(data.c_str(), data.size(), mimetype, false) != Result::Success) { /* mPicture is not handled as unique_ptr yet, so delete here */ delete(mPicture); mPicture = nullptr; @@ -75,6 +75,8 @@ public: return false; } + mPicture->size(&mOriginalSize[0], &mOriginalSize[1]); + /* need to reset size to calculate scale in Picture.size internally before calling updateSize */ mWidth = 0; @@ -131,6 +133,11 @@ public: return val(typed_memory_view(mWidth * mHeight * 4, mBuffer.get())); } + val originalSize() + { + return val(typed_memory_view(2, mOriginalSize)); + } + bool saveTvg() { mErrorMsg = "None"; @@ -184,6 +191,7 @@ private: uint32_t mWidth{0}; uint32_t mHeight{0}; + float mOriginalSize[2]; }; // Binding code @@ -195,6 +203,7 @@ EMSCRIPTEN_BINDINGS(thorvg_bindings) { .function("load", &ThorvgWasm::load) .function("update", &ThorvgWasm::update) .function("render", &ThorvgWasm::render) + .function("originalSize", &ThorvgWasm::originalSize) .function("saveTvg", &ThorvgWasm::saveTvg); }