mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-25 20:02:34 +00:00
@@ -202,14 +202,17 @@ impl BitMatrix {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Gets the requested bit, where true means black.</p>
|
||||
* Gets the requested bit, where true means black.
|
||||
*
|
||||
* @param x The horizontal component (i.e. which column)
|
||||
* @param y The vertical component (i.e. which row)
|
||||
* @return value of given bit in matrix
|
||||
* x The horizontal component (i.e. which column)
|
||||
* y The vertical component (i.e. which row)
|
||||
* returns the value of given bit in matrix, or false if the requested point is out of bounds of the image
|
||||
*/
|
||||
pub fn get(&self, x: u32, y: u32) -> bool {
|
||||
let offset = self.get_offset(y, x);
|
||||
if offset >= self.bits.len() {
|
||||
return false;
|
||||
}
|
||||
((self.bits[offset] >> (x & 0x1f)) & 1) != 0
|
||||
}
|
||||
|
||||
@@ -232,6 +235,10 @@ impl BitMatrix {
|
||||
Some(((self.bits[offset] >> (x & 0x1f)) & 1) != 0)
|
||||
}
|
||||
|
||||
pub fn try_get_point(&self, point: Point) -> Option<bool> {
|
||||
self.try_get(point.x as u32, point.y as u32)
|
||||
}
|
||||
|
||||
pub fn try_get_area(&self, x: u32, y: u32, box_size: u32) -> Option<bool> {
|
||||
let mut matrix = Vec::with_capacity((box_size * box_size) as usize);
|
||||
let start_x = (x as i32 - box_size as i32 / 2).max(0) as u32;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
File diff suppressed because one or more lines are too long
24
tests/github_issues.rs
Normal file
24
tests/github_issues.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use std::io::Read;
|
||||
|
||||
use rxing::DecodingHintDictionary;
|
||||
|
||||
#[test]
|
||||
fn issue_27_part_2() {
|
||||
let mut data = Vec::new();
|
||||
std::fs::File::open("test_resources/blackbox/github_issue_cases/226611447-be6041dc-5b21-42fe-827b-068ccc59082c.png")
|
||||
.unwrap()
|
||||
.read_to_end(&mut data)
|
||||
.unwrap();
|
||||
|
||||
rxing::helpers::detect_multiple_in_luma(data, 720, 618).unwrap_or_default();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_28() {
|
||||
let mut hints: DecodingHintDictionary = DecodingHintDictionary::new();
|
||||
hints.insert(
|
||||
rxing::DecodeHintType::TRY_HARDER,
|
||||
rxing::DecodeHintValue::TryHarder(true),
|
||||
);
|
||||
rxing::helpers::detect_multiple_in_file_with_hints("test_resources/blackbox/github_issue_cases/226611447-be6041dc-5b21-42fe-827b-068ccc59082c.png", &mut hints).unwrap_or_default();
|
||||
}
|
||||
Reference in New Issue
Block a user