mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +00:00
LibGUI: Pass ideal size when requesting thumbnail bitmaps
This makes thumbnails for vector graphics look much nicer :^)
This commit is contained in:
parent
90e836deae
commit
8784568a36
1 changed files with 4 additions and 3 deletions
|
@ -663,10 +663,11 @@ static Threading::MutexProtected<ThumbnailCache> s_thumbnail_cache {};
|
|||
|
||||
static ErrorOr<NonnullRefPtr<Gfx::Bitmap>> render_thumbnail(StringView path)
|
||||
{
|
||||
auto bitmap = TRY(Gfx::Bitmap::load_from_file(path));
|
||||
auto thumbnail = TRY(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { 32, 32 }));
|
||||
Gfx::IntSize thumbnail_size { 32, 32 };
|
||||
auto bitmap = TRY(Gfx::Bitmap::load_from_file(path, 1, thumbnail_size));
|
||||
auto thumbnail = TRY(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, thumbnail_size));
|
||||
|
||||
double scale = min(32 / (double)bitmap->width(), 32 / (double)bitmap->height());
|
||||
double scale = min(thumbnail_size.width() / (double)bitmap->width(), thumbnail_size.height() / (double)bitmap->height());
|
||||
auto destination = Gfx::IntRect(0, 0, (int)(bitmap->width() * scale), (int)(bitmap->height() * scale)).centered_within(thumbnail->rect());
|
||||
|
||||
Painter painter(thumbnail);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue