From 4b6a03ef564044bda9f92cdf4bff886f1b8a90fb Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Sun, 23 Jul 2023 12:48:04 +0200 Subject: [PATCH] for zbar scans, return scanned characters as raw bytes --- drongo | 2 +- src/main/java/net/sourceforge/zbar/ZBar.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drongo b/drongo index e15eb7c7..d7b97c99 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit e15eb7c7f36756c35577d61bfd793b2a2502cf93 +Subproject commit d7b97c99dcd1aa593e7c4354652cd8068aaaeccb diff --git a/src/main/java/net/sourceforge/zbar/ZBar.java b/src/main/java/net/sourceforge/zbar/ZBar.java index 112b8580..abe136a3 100644 --- a/src/main/java/net/sourceforge/zbar/ZBar.java +++ b/src/main/java/net/sourceforge/zbar/ZBar.java @@ -49,7 +49,7 @@ public class ZBar { Scan scan = null; for(Iterator iter = results.iterator(); iter.hasNext(); ) { try(Symbol symbol = iter.next()) { - scan = new Scan(symbol.getDataBytes(), symbol.getData()); + scan = new Scan(getRawBytes(symbol.getData()), symbol.getData()); } } return scan; @@ -122,5 +122,15 @@ public class ZBar { return false; } + private static byte[] getRawBytes(String str) { + char[] chars = str.toCharArray(); + byte[] bytes = new byte[chars.length]; + for(int i = 0; i < chars.length; i++) { + bytes[i] = (byte)(chars[i]); + } + + return bytes; + } + public record Scan(byte[] rawData, String stringData) {} }