Skip to content

Commit

Permalink
Merge pull request #8 from cpwood/main
Browse files Browse the repository at this point in the history
Telepen numeric support
  • Loading branch information
hschimke authored Jan 3, 2024
2 parents a757634 + 78c4263 commit bc161bc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/webpack+js/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ <h1>RXing - Decode Barcodes</h1>
<label for="AllowedEanExtensions">AllowedEanExtensions:</label><input type="text" name="AllowedEanExtensions"
id="AllowedEanExtensions" />
<label for="AlsoInverted">AlsoInverted:</label><input type="checkbox" name="AlsoInverted" id="AlsoInverted" />
<label for="TelepenAsNumeric">TelepenAsNumeric:</label><input type="checkbox" name="TelepenAsNumeric" id="TelepenAsNumeric" />
</div>
<input type="file" id="image_file_input" />
<button id="scan_btn" disabled="true">Scan</button>
Expand Down
2 changes: 1 addition & 1 deletion examples/webpack+js/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { convert_js_image_to_luma, decode_barcode_with_hints, DecodeHintDictionary, DecodeHintTypes, BarcodeFormat } from "rxing-wasm";

const text_hints = ["Other", "PossibleFormats", "CharacterSet", "AllowedLengths", "AllowedEanExtensions"];
const bool_hints = ["PureBarcode", "TryHarder", "AssumeCode39CheckDigit", "ReturnCodabarStartEnd", "AssumeGs1", "AlsoInverted"]
const bool_hints = ["PureBarcode", "TryHarder", "AssumeCode39CheckDigit", "ReturnCodabarStartEnd", "AssumeGs1", "AlsoInverted", "TelepenAsNumeric"]

const scan_btn = document.getElementById('scan_btn');
const input = document.getElementById('image_file_input');
Expand Down
14 changes: 14 additions & 0 deletions src/decode_hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ pub enum DecodeHintTypes {
* second time with an inverted image. Doesn't matter what it maps to; use {@link Boolean#TRUE}.
*/
AlsoInverted,


/**
* Translate the ASCII values parsed by the Telepen reader into the Telepen Numeric form; use {@link Boolean#TRUE}.
*/
TelepenAsNumeric,
}

impl From<DecodeHintTypes> for rxing::DecodeHintType {
Expand All @@ -99,6 +105,7 @@ impl From<DecodeHintTypes> for rxing::DecodeHintType {
}
DecodeHintTypes::AllowedEanExtensions => rxing::DecodeHintType::ALLOWED_EAN_EXTENSIONS,
DecodeHintTypes::AlsoInverted => rxing::DecodeHintType::ALSO_INVERTED,
DecodeHintTypes::TelepenAsNumeric => rxing::DecodeHintType::TELEPEN_AS_NUMERIC,
}
}
}
Expand Down Expand Up @@ -237,6 +244,13 @@ impl DecodeHintDictionary {
rxing::DecodeHintValue::AlsoInverted(also_inverted),
);
}
DecodeHintTypes::TelepenAsNumeric => {
let Ok(telepen_as_numeric) = value.parse() else {
return false;
};
self.0
.insert(hint.into(), rxing::DecodeHintValue::TelepenAsNumeric(telepen_as_numeric));
}
}
true
}
Expand Down

0 comments on commit bc161bc

Please sign in to comment.