mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
chore: cargo fmt
This commit is contained in:
@@ -530,7 +530,7 @@ impl BitMatrix {
|
|||||||
if theBits != 0 {
|
if theBits != 0 {
|
||||||
top = top.min(y);
|
top = top.min(y);
|
||||||
bottom = bottom.max(y);
|
bottom = bottom.max(y);
|
||||||
|
|
||||||
if x32 * 32 < left as usize {
|
if x32 * 32 < left as usize {
|
||||||
let mut bit = 0;
|
let mut bit = 0;
|
||||||
while (theBits << (31 - bit)) == 0 {
|
while (theBits << (31 - bit)) == 0 {
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ impl<LS: LuminanceSource> GlobalHistogramBinarizer<LS> {
|
|||||||
let row = height * y / 5;
|
let row = height * y / 5;
|
||||||
let localLuminances = source.get_row(row);
|
let localLuminances = source.get_row(row);
|
||||||
let right = (width * 4) / 5;
|
let right = (width * 4) / 5;
|
||||||
for x in (width/5)..right {
|
for x in (width / 5)..right {
|
||||||
let pixel = localLuminances[x];
|
let pixel = localLuminances[x];
|
||||||
localBuckets[(pixel >> LUMINANCE_SHIFT) as usize] += 1;
|
localBuckets[(pixel >> LUMINANCE_SHIFT) as usize] += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,12 +172,7 @@ pub trait GridSampler {
|
|||||||
}
|
}
|
||||||
// dbg!(bits.to_string());
|
// dbg!(bits.to_string());
|
||||||
|
|
||||||
Ok((
|
Ok((bits, [Point::default(); 4]))
|
||||||
bits,
|
|
||||||
[
|
|
||||||
Point::default();4
|
|
||||||
],
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -170,11 +170,11 @@ impl<LS: LuminanceSource> HybridBinarizer<LS> {
|
|||||||
for y in 0..sub_height {
|
for y in 0..sub_height {
|
||||||
// for (int y = 0; y < subHeight; y++) {
|
// for (int y = 0; y < subHeight; y++) {
|
||||||
let yoffset = u32::min(y << BLOCK_SIZE_POWER, maxYOffset);
|
let yoffset = u32::min(y << BLOCK_SIZE_POWER, maxYOffset);
|
||||||
|
|
||||||
let top = Self::cap(y, sub_height - 3);
|
let top = Self::cap(y, sub_height - 3);
|
||||||
for x in 0..sub_width {
|
for x in 0..sub_width {
|
||||||
// for (int x = 0; x < subWidth; x++) {
|
// for (int x = 0; x < subWidth; x++) {
|
||||||
let xoffset = u32::min(x << BLOCK_SIZE_POWER,maxXOffset);
|
let xoffset = u32::min(x << BLOCK_SIZE_POWER, maxXOffset);
|
||||||
|
|
||||||
let left = Self::cap(x, sub_width - 3);
|
let left = Self::cap(x, sub_width - 3);
|
||||||
let mut sum = 0;
|
let mut sum = 0;
|
||||||
@@ -240,12 +240,12 @@ impl<LS: LuminanceSource> HybridBinarizer<LS> {
|
|||||||
let mut blackPoints = vec![vec![0; subWidth as usize]; subHeight as usize];
|
let mut blackPoints = vec![vec![0; subWidth as usize]; subHeight as usize];
|
||||||
for y in 0..subHeight {
|
for y in 0..subHeight {
|
||||||
// for (int y = 0; y < subHeight; y++) {
|
// for (int y = 0; y < subHeight; y++) {
|
||||||
let yoffset = u32::min(y << BLOCK_SIZE_POWER,maxYOffset as u32);
|
let yoffset = u32::min(y << BLOCK_SIZE_POWER, maxYOffset as u32);
|
||||||
|
|
||||||
for x in 0..subWidth {
|
for x in 0..subWidth {
|
||||||
// for (int x = 0; x < subWidth; x++) {
|
// for (int x = 0; x < subWidth; x++) {
|
||||||
let xoffset = u32::min(x << BLOCK_SIZE_POWER,maxXOffset as u32);
|
let xoffset = u32::min(x << BLOCK_SIZE_POWER, maxXOffset as u32);
|
||||||
|
|
||||||
let mut sum: u32 = 0;
|
let mut sum: u32 = 0;
|
||||||
let mut min = 0xff;
|
let mut min = 0xff;
|
||||||
let mut max = 0;
|
let mut max = 0;
|
||||||
|
|||||||
@@ -92,11 +92,9 @@ impl StringUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// First try UTF-16, assuming anything with its BOM is UTF-16
|
// First try UTF-16, assuming anything with its BOM is UTF-16
|
||||||
|
|
||||||
if bytes.len() > 2
|
if bytes.len() > 2 && ((bytes[0..=1] == [0xFE, 0xFF]) || (bytes[0..=1] == [0xFF, 0xFE])) {
|
||||||
&& ((bytes[0..=1] == [0xFE,0xFF]) || (bytes[0..=1] == [0xFF , 0xFE]))
|
if bytes[0..=1] == [0xFE, 0xFF] {
|
||||||
{
|
|
||||||
if bytes[0..=1] == [0xFE , 0xFF] {
|
|
||||||
return Some(CharacterSet::UTF16BE);
|
return Some(CharacterSet::UTF16BE);
|
||||||
} else {
|
} else {
|
||||||
return Some(CharacterSet::UTF16LE);
|
return Some(CharacterSet::UTF16LE);
|
||||||
@@ -121,7 +119,7 @@ impl StringUtils {
|
|||||||
let mut sjis_max_double_bytes_word_length = 0;
|
let mut sjis_max_double_bytes_word_length = 0;
|
||||||
let mut iso_high_other = 0;
|
let mut iso_high_other = 0;
|
||||||
|
|
||||||
let utf8bom = bytes.len() > 3 && bytes[0..=2] == [ 0xEF , 0xBB , 0xBF];
|
let utf8bom = bytes.len() > 3 && bytes[0..=2] == [0xEF, 0xBB, 0xBF];
|
||||||
|
|
||||||
// for i in 0..length {
|
// for i in 0..length {
|
||||||
for value in bytes.iter().take(length).copied() {
|
for value in bytes.iter().take(length).copied() {
|
||||||
|
|||||||
@@ -71,12 +71,8 @@ impl OneDReader for TelepenReader {
|
|||||||
// largest gaps.
|
// largest gaps.
|
||||||
while j <= end {
|
while j <= end {
|
||||||
let currentCounter = theCounters[j];
|
let currentCounter = theCounters[j];
|
||||||
if currentCounter < minBar {
|
minBar = u32::min(currentCounter, minBar);
|
||||||
minBar = currentCounter;
|
maxBar = u32::max(currentCounter, maxBar);
|
||||||
}
|
|
||||||
if currentCounter > maxBar {
|
|
||||||
maxBar = currentCounter;
|
|
||||||
}
|
|
||||||
|
|
||||||
j += 1;
|
j += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user