Add option to output raw bitstream from CommandLineRunner. (#1442)

* Add option to output raw bitstream from CommandLineRunner.
Useful for debugging barcodes. Same as the web decoder.

* Use StringBuilder. Fix indentation.
This commit is contained in:
Anders Hammarquist 2021-09-28 22:27:49 +02:00 committed by GitHub
parent be2c5bdd88
commit 83650ce341
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -165,6 +165,19 @@ final class DecodeWorker implements Callable<Integer> {
result.getText() + "\n" +
"Parsed result:\n" +
parsedResult.getDisplayResult() + "\n");
if (config.outputRaw) {
StringBuilder rawData = new StringBuilder();
for (byte b : result.getRawBytes()) {
rawData.append(String.format("%02X", b & 0xff));
rawData.append(" ");
}
rawData.setLength(rawData.length() - 1); // chop off final space
output.write("Raw bits:\n" + rawData.toString() + "\n");
}
ResultPoint[] resultPoints = result.getResultPoints();
int numResultPoints = resultPoints.length;
output.write("Found " + numResultPoints + " result points.\n");

View file

@ -58,6 +58,10 @@ final class DecoderConfig {
description = "Only output one line per file, omitting the contents")
boolean brief;
@Parameter(names = "--raw",
description = "Output raw bitstream, before decoding symbols")
boolean outputRaw;
@Parameter(names = "--recursive",
description = "Descend into subdirectories")
boolean recursive;