Skip to content

Commit

Permalink
No error if no non-transparent pixel found.
Browse files Browse the repository at this point in the history
  • Loading branch information
amandeepg committed Mar 3, 2024
1 parent 09d4938 commit e29f320
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand All @@ -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(
Expand Down

0 comments on commit e29f320

Please sign in to comment.