Skip to content

Add hex value to wasm result #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ CMakeLists.txt.user
*.d
*.a
compile_commands.json
build/
.vscode/
4 changes: 3 additions & 1 deletion wrappers/wasm/BarcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct ReadResult
{
std::string format{};
std::string text{};
std::string hex{};
std::string error{};
Position position{};
std::string symbologyIdentifier{};
Expand All @@ -43,7 +44,7 @@ std::vector<ReadResult> readBarcodes(ImageView iv, bool tryHarder, const std::st
readResults.reserve(results.size());

for (auto& result : results) {
readResults.push_back({ToString(result.format()), result.text(), ToString(result.error()), result.position(), result.symbologyIdentifier()});
readResults.push_back({ToString(result.format()), result.text(), ToHex(result.bytes()), ToString(result.error()), result.position(), result.symbologyIdentifier()});
}

return readResults;
Expand Down Expand Up @@ -89,6 +90,7 @@ EMSCRIPTEN_BINDINGS(BarcodeReader)
value_object<ReadResult>("ReadResult")
.field("format", &ReadResult::format)
.field("text", &ReadResult::text)
.field("hex", &ReadResult::hex)
.field("error", &ReadResult::error)
.field("position", &ReadResult::position)
.field("symbologyIdentifier", &ReadResult::symbologyIdentifier);
Expand Down
7 changes: 5 additions & 2 deletions wrappers/wasm/demo_reader.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@
}
else {
for (let i = 0; i < results.size(); i += 1) {
const { error, format, text } = results.get(i);
resultsDiv.innerHTML += "<li>Format: <strong>" + format + "</strong><pre>" + (text || '<font color="red">Error: ' + error + '</font>') + "</pre></li>";
const { error, format, text, hex } = results.get(i);
resultsDiv.innerHTML += "<li>Format: <strong>" + format + "</strong>"
+ "<p>Hex:" + hex + "</p>"
+ "<pre><a>" + (text || '<font color="red">Error: ' + error + '</font>') + "</a></pre>"+
+"</li>";
}
}
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy