mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-01 21:59:11 +00:00
Bitmap: Don't call Bitmap::create with width/height equal to 0
With very small bitmaps and small scale factor, such as tile.png, the type conversion in the call to Bitmap:create would cause width or height to be 0. Fixes #7352
This commit is contained in:
parent
1ae18c1228
commit
ee48dac300
Notes:
sideshowbarker
2024-07-18 17:33:43 +09:00
Author: https://github.com/metmo
Commit: ee48dac300
Pull-request: https://github.com/SerenityOS/serenity/pull/7365
Issue: https://github.com/SerenityOS/serenity/issues/7352
1 changed files with 4 additions and 1 deletions
|
@ -427,7 +427,10 @@ RefPtr<Gfx::Bitmap> Bitmap::scaled(float sx, float sy) const
|
|||
if (floorf(sx) == sx && floorf(sy) == sy)
|
||||
return scaled(static_cast<int>(sx), static_cast<int>(sy));
|
||||
|
||||
auto new_bitmap = Gfx::Bitmap::create(format(), { width() * sx, height() * sy }, scale());
|
||||
int scaled_width = (int)ceilf(sx * (float)width());
|
||||
int scaled_height = (int)ceilf(sy * (float)height());
|
||||
|
||||
auto new_bitmap = Gfx::Bitmap::create(format(), { scaled_width, scaled_height }, scale());
|
||||
if (!new_bitmap)
|
||||
return nullptr;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue