for zbar scans, return scanned characters as raw bytes

This commit is contained in:
Craig Raw 2023-07-23 12:48:04 +02:00
parent 7ff4230e13
commit 4b6a03ef56
2 changed files with 12 additions and 2 deletions

2
drongo

@ -1 +1 @@
Subproject commit e15eb7c7f36756c35577d61bfd793b2a2502cf93 Subproject commit d7b97c99dcd1aa593e7c4354652cd8068aaaeccb

View file

@ -49,7 +49,7 @@ public class ZBar {
Scan scan = null; Scan scan = null;
for(Iterator<Symbol> iter = results.iterator(); iter.hasNext(); ) { for(Iterator<Symbol> iter = results.iterator(); iter.hasNext(); ) {
try(Symbol symbol = iter.next()) { try(Symbol symbol = iter.next()) {
scan = new Scan(symbol.getDataBytes(), symbol.getData()); scan = new Scan(getRawBytes(symbol.getData()), symbol.getData());
} }
} }
return scan; return scan;
@ -122,5 +122,15 @@ public class ZBar {
return false; 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) {} public record Scan(byte[] rawData, String stringData) {}
} }