commit e1de40ffd00933d6e976656d08cce2c237522a20
parent 2028c212a07bab3830f8e12143ac37e2f9f67168
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 30 Mar 2023 01:00:53 -0700
cleanup
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/lechatphp/mod.rs b/src/lechatphp/mod.rs
@@ -464,11 +464,12 @@ fn has_red_in_center_area(letter_img: &DynamicImage) -> bool {
// Count pixels that are On (either white or red)
fn count_px_on(img: &DynamicImage) -> usize {
let mut count_on = 0;
- for y in 0..std::cmp::min(img.dimensions().1, 14) {
- for x in 0..std::cmp::min(img.dimensions().0, 8) {
- let c = img.get_pixel(x, y);
- if c == *ON_COLOR || c == *RED_COLOR {
- count_on += 1
+ for y in 0..14 {
+ for x in 0..8 {
+ if let Some(c) = get_pixel_in_bound(img, x, y) {
+ if c == *ON_COLOR || c == *RED_COLOR {
+ count_on += 1
+ }
}
}
}