Skip to content

Commit

Permalink
Fixes wasm (#54) (#55)
Browse files Browse the repository at this point in the history
* refer to the generic module

* from qt6.6.0 malloc and free are in the js API
  • Loading branch information
EddyTheCo authored Nov 11, 2023
1 parent 80fad4e commit 7414aa2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 5 additions & 4 deletions QtQrDec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ if (Qt6_FOUND AND TARGET QrDec)
URI QtQrDec
VERSION 1.0
SOURCES Qrimagedecoder.cpp include/Qrimagedecoder.hpp
QML_FILES
qml/QrQmlCamera.qml
QML_FILES
qml/QrQmlCamera.qml
qml/QrCam.qml
qml/QrTextCamPop.qml
RESOURCE_PREFIX
Expand All @@ -24,10 +24,11 @@ if (Qt6_FOUND AND TARGET QrDec)
${CMAKE_BINARY_DIR}/QtQrDec
IMPORT_PATH ${CMAKE_BINARY_DIR}
)

target_include_directories(QtQrDec PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/qrCode>")

target_link_libraries(QtQrDec PUBLIC Qt6::Gui Qt6::Quick QrDec $<TARGET_NAME_IF_EXISTS:Qt6::Multimedia> MyDesigns
target_link_libraries(QtQrDec PUBLIC Qt6::Gui Qt6::Quick QrDec $<TARGET_NAME_IF_EXISTS:Qt6::Multimedia> MyDesigns
$<$<STREQUAL:$<TARGET_PROPERTY:MyDesigns,TYPE>,STATIC_LIBRARY>:MyDesignsplugin>)

install(TARGETS QtQrDec QtQrDecplugin ${out_targets_var}
Expand All @@ -45,6 +46,6 @@ if (Qt6_FOUND AND TARGET QrDec)
)

if(EMSCRIPTEN)
target_compile_definitions(QtQrDec PUBLIC USE_EMSCRIPTEN)
target_compile_definitions(QtQrDec PRIVATE USE_EMSCRIPTEN)
endif(EMSCRIPTEN)
endif(Qt6_FOUND AND TARGET QrDec)
9 changes: 4 additions & 5 deletions QtQrDec/Qrimagedecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ EM_JS(void, js_start, (), {
let canvas = document.querySelector("#qrcanvas");
let ctx=canvas.getContext("2d");
const processFrame = function () {
//You need to define qtQR module when loading the module of the qt application.
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const sourceBuffer = imageData.data;
const buffer = qtQR._malloc(sourceBuffer.byteLength);
qtQR.HEAPU8.set(sourceBuffer, buffer);
qtQR.QRImageDecoder.getdecoder().reload(buffer,video.width,video.height);
qtQR._free(buffer);
const buffer = _malloc(sourceBuffer.byteLength);
HEAPU8.set(sourceBuffer, buffer);
Module.QRImageDecoder.getdecoder().reload(buffer,video.width,video.height);
_free(buffer);
if(window.localStream.active)
{
requestAnimationFrame(processFrame);
Expand Down

0 comments on commit 7414aa2

Please sign in to comment.