mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:18:11 +00:00
LibGfx: Add Bitmap::scaled_to_size()
This commit is contained in:
parent
3907374621
commit
a4dec92ed0
2 changed files with 7 additions and 2 deletions
|
@ -362,7 +362,6 @@ ErrorOr<NonnullRefPtr<Gfx::Bitmap>> Bitmap::scaled(int sx, int sy) const
|
|||
return new_bitmap;
|
||||
}
|
||||
|
||||
// http://fourier.eng.hmc.edu/e161/lectures/resize/node3.html
|
||||
ErrorOr<NonnullRefPtr<Gfx::Bitmap>> Bitmap::scaled(float sx, float sy) const
|
||||
{
|
||||
VERIFY(sx >= 0.0f && sy >= 0.0f);
|
||||
|
@ -371,8 +370,13 @@ ErrorOr<NonnullRefPtr<Gfx::Bitmap>> Bitmap::scaled(float sx, float sy) const
|
|||
|
||||
int scaled_width = (int)ceilf(sx * (float)width());
|
||||
int scaled_height = (int)ceilf(sy * (float)height());
|
||||
return scaled_to_size({ scaled_width, scaled_height });
|
||||
}
|
||||
|
||||
auto new_bitmap = TRY(Gfx::Bitmap::create(format(), { scaled_width, scaled_height }, scale()));
|
||||
// http://fourier.eng.hmc.edu/e161/lectures/resize/node3.html
|
||||
ErrorOr<NonnullRefPtr<Gfx::Bitmap>> Bitmap::scaled_to_size(Gfx::IntSize size) const
|
||||
{
|
||||
auto new_bitmap = TRY(Gfx::Bitmap::create(format(), size, scale()));
|
||||
|
||||
auto old_width = physical_width();
|
||||
auto old_height = physical_height();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue