mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-20 08:22:19 +00:00
PixelPaint: Reduce verbosity of crop to content feature
This patch reduces the repetitiveness of the crop to content feature implementation.
This commit is contained in:
parent
d5de9bcc51
commit
21358d8a5f
|
@ -540,7 +540,7 @@ Optional<Gfx::IntRect> Image::nonempty_content_bounding_rect() const
|
||||||
auto layer_content_rect_in_layer_coordinates = layer.nonempty_content_bounding_rect();
|
auto layer_content_rect_in_layer_coordinates = layer.nonempty_content_bounding_rect();
|
||||||
if (!layer_content_rect_in_layer_coordinates.has_value())
|
if (!layer_content_rect_in_layer_coordinates.has_value())
|
||||||
continue;
|
continue;
|
||||||
auto layer_content_rect_in_image_coordinates = layer_content_rect_in_layer_coordinates.value().translated(layer.location());
|
auto layer_content_rect_in_image_coordinates = layer_content_rect_in_layer_coordinates->translated(layer.location());
|
||||||
if (!bounding_rect.has_value())
|
if (!bounding_rect.has_value())
|
||||||
bounding_rect = layer_content_rect_in_image_coordinates;
|
bounding_rect = layer_content_rect_in_image_coordinates;
|
||||||
else
|
else
|
||||||
|
|
|
@ -281,26 +281,10 @@ Optional<Gfx::IntRect> Layer::nonempty_content_bounding_rect() const
|
||||||
auto color = m_content_bitmap->get_pixel(x, y);
|
auto color = m_content_bitmap->get_pixel(x, y);
|
||||||
if (color.alpha() == 0)
|
if (color.alpha() == 0)
|
||||||
continue;
|
continue;
|
||||||
|
min_content_x = min(min_content_x.value_or(x), x);
|
||||||
if (!min_content_x.has_value())
|
min_content_y = min(min_content_y.value_or(y), y);
|
||||||
min_content_x = x;
|
max_content_x = max(max_content_x.value_or(x), x);
|
||||||
else
|
max_content_y = max(max_content_y.value_or(y), y);
|
||||||
min_content_x = min(*min_content_x, x);
|
|
||||||
|
|
||||||
if (!min_content_y.has_value())
|
|
||||||
min_content_y = y;
|
|
||||||
else
|
|
||||||
min_content_y = min(*min_content_y, y);
|
|
||||||
|
|
||||||
if (!max_content_x.has_value())
|
|
||||||
max_content_x = x;
|
|
||||||
else
|
|
||||||
max_content_x = max(*max_content_x, x);
|
|
||||||
|
|
||||||
if (!max_content_y.has_value())
|
|
||||||
max_content_y = y;
|
|
||||||
else
|
|
||||||
max_content_y = max(*max_content_y, y);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue