mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
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:
parent
be2c5bdd88
commit
83650ce341
|
@ -165,6 +165,19 @@ final class DecodeWorker implements Callable<Integer> {
|
||||||
result.getText() + "\n" +
|
result.getText() + "\n" +
|
||||||
"Parsed result:\n" +
|
"Parsed result:\n" +
|
||||||
parsedResult.getDisplayResult() + "\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();
|
ResultPoint[] resultPoints = result.getResultPoints();
|
||||||
int numResultPoints = resultPoints.length;
|
int numResultPoints = resultPoints.length;
|
||||||
output.write("Found " + numResultPoints + " result points.\n");
|
output.write("Found " + numResultPoints + " result points.\n");
|
||||||
|
|
|
@ -58,6 +58,10 @@ final class DecoderConfig {
|
||||||
description = "Only output one line per file, omitting the contents")
|
description = "Only output one line per file, omitting the contents")
|
||||||
boolean brief;
|
boolean brief;
|
||||||
|
|
||||||
|
@Parameter(names = "--raw",
|
||||||
|
description = "Output raw bitstream, before decoding symbols")
|
||||||
|
boolean outputRaw;
|
||||||
|
|
||||||
@Parameter(names = "--recursive",
|
@Parameter(names = "--recursive",
|
||||||
description = "Descend into subdirectories")
|
description = "Descend into subdirectories")
|
||||||
boolean recursive;
|
boolean recursive;
|
||||||
|
|
Loading…
Reference in a new issue