From e29f320b7be400e144fbcc16cb5bb832ac166e3b Mon Sep 17 00:00:00 2001 From: Amandeep Grewal Date: Sat, 2 Mar 2024 23:19:47 -0500 Subject: [PATCH] No error if no non-transparent pixel found. --- src/main.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0d3c16f..bd5de35 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ use std::time::Instant; use crate::args::Args; use crate::duration_ext::DurationExt; -use anyhow::{anyhow, Context, Result}; +use anyhow::{Context, Result}; use clap::Parser; use colored::Colorize; use human_bytes::human_bytes; @@ -38,7 +38,7 @@ fn search_for_non_transparent_pixel( let mut center_x = width / (100 / top_search_axis as u32); let mut center_y = height / (100 / left_search_axis as u32); - while center_y > 0 && center_x > 0 && center_x < width && center_y < height { + while center_y > 0 && center_x > 0 && center_x < width - 1 && center_y < height - 1 { if img.get_pixel(center_x, center_y)[3] == 255 { return Ok((center_x, center_y)); } @@ -50,10 +50,7 @@ fn search_for_non_transparent_pixel( } } - Err(anyhow!( - "Could not find non-transparent pixel in direction {:?}", - dir - )) + Ok((center_x, center_y)) } fn find_transparent_pixels(