Skip to content

Commit

Permalink
Fixed trim none
Browse files Browse the repository at this point in the history
  • Loading branch information
houmain committed May 28, 2023
1 parent 3d1342d commit 713067f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/trimming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,19 @@ namespace {
}

void trim_sprite(Sprite& sprite) {
if (sprite.trim == Trim::none) {

if (sprite.trim != Trim::none) {
sprite.trimmed_source_rect = get_used_bounds(*sprite.source,
sprite.trim_gray_levels, sprite.trim_threshold, sprite.source_rect);

if (sprite.trim_margin)
sprite.trimmed_source_rect = intersect(expand(
sprite.trimmed_source_rect, sprite.trim_margin), sprite.source_rect);
}
else {
sprite.trimmed_source_rect = sprite.source_rect;
return;
}

sprite.trimmed_source_rect = get_used_bounds(*sprite.source,
sprite.trim_gray_levels, sprite.trim_threshold, sprite.source_rect);

if (sprite.trim_margin)
sprite.trimmed_source_rect = intersect(expand(
sprite.trimmed_source_rect, sprite.trim_margin), sprite.source_rect);

if (sprite.trim == Trim::convex) {
const auto levels = (sprite.trim_gray_levels ?
get_gray_levels(*sprite.source, sprite.trimmed_source_rect) :
Expand Down

0 comments on commit 713067f

Please sign in to comment.