Skip to content

Commit

Permalink
improved performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Comeza committed Mar 13, 2021
1 parent d48db34 commit 4b0cdce
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/img.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,20 @@ pub fn process_images(

match direction {
WriteDirection::Y => {
'outer_y: for x in 0..(buffer_dim_x / img_dim_x) {
for x in 0..(buffer_dim_x / img_dim_x) {
for y in 0..(buffer_dim_y / img_dim_y) {
let has_processed = overlay_image(index, files, image_buffer, &img_dim, x, y);
overlay_image(index, files, image_buffer, &img_dim, x, y);
index += 1;
progress_bar.inc(1);
if !has_processed {
break 'outer_y;
}
}
}
}
WriteDirection::X => {
'outer_x: for y in 0..(buffer_dim_y / img_dim_y) {
for y in 0..(buffer_dim_y / img_dim_y) {
for x in 0..(buffer_dim_x / img_dim_x) {
let has_processed = overlay_image(index, files, image_buffer, &img_dim, x, y);
overlay_image(index, files, image_buffer, &img_dim, x, y);
index += 1;
progress_bar.inc(1);
if !has_processed {
break 'outer_x;
}
}
}
}
Expand All @@ -56,7 +50,7 @@ fn overlay_image(
img_dim: &Dimensions<u32>,
x: u32,
y: u32,
) -> bool {
) {
match files.get(index) {
Some(path) => {
imageops::overlay(
Expand All @@ -65,9 +59,8 @@ fn overlay_image(
x * img_dim.x,
y * img_dim.y,
);
true
}
None => false,
None => (),
}
}

Expand Down

0 comments on commit 4b0cdce

Please sign in to comment.