mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-12 22:22:55 +00:00
LibGfx: Add a draw_scaled_bitmap() variant that takes a FloatRect as src_rect
Consider draw_scaled_bitmap({0, 0, 10, 10}, source, {0, 0, 5, 5}). Imagine wanting to split that up into two calls, like e.g. the compositor when redrawing the background with damage rects. You really want to be able to say draw_scaled_bitmap({0, 0, 5, 10}, source, {0, 0, 2.5, 5}) but up to now you couldn't. Now you can. This makes painting very low-res images (such as tile.png) in mode "stretch" work much better.
This commit is contained in:
parent
7278ff6605
commit
2ec6bbd7a1
Notes:
sideshowbarker
2024-07-18 22:59:40 +09:00
Author: https://github.com/nico
Commit: 2ec6bbd7a1
Pull-request: https://github.com/SerenityOS/serenity/pull/5054
4 changed files with 31 additions and 20 deletions
|
@ -100,8 +100,8 @@ void Canvas::draw(Gfx::Painter& painter)
|
|||
|
||||
auto buggie = Gfx::Bitmap::load_from_file("/res/graphics/buggie.png");
|
||||
painter.blit({ 25, 39 }, *buggie, { 2, 30, 62, 20 });
|
||||
painter.draw_scaled_bitmap({ 88, 39, 62 * 2, 20 * 2 }, *buggie, { 2, 30, 62, 20 });
|
||||
painter.draw_scaled_bitmap({ 202, 39, 80, 40 }, *buggie, { 2, 30, 62, 20 });
|
||||
painter.draw_scaled_bitmap({ 88, 39, 62 * 2, 20 * 2 }, *buggie, Gfx::IntRect { 2, 30, 62, 20 });
|
||||
painter.draw_scaled_bitmap({ 202, 39, 80, 40 }, *buggie, Gfx::IntRect { 2, 30, 62, 20 });
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue