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
+11 -1
View File
@@ -49,7 +49,7 @@ public class ZBar {
Scan scan = null;
for(Iterator<Symbol> 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) {}
}