From 435e53fcfec74405fbd2be102b9fd8ebb214707f Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Sun, 21 Aug 2022 15:53:59 +0100 Subject: [PATCH] LibCards: Remove card-back-image scaling This was giving wonky results with images that do not fill the entire card - and it's also unnecessary, since the Buggie image we have been using, and the two I will be adding, are all small enough to not need scaling anyway. :^) --- Userland/Libraries/LibCards/CardPainter.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibCards/CardPainter.cpp b/Userland/Libraries/LibCards/CardPainter.cpp index a141863b44..b8c583d077 100644 --- a/Userland/Libraries/LibCards/CardPainter.cpp +++ b/Userland/Libraries/LibCards/CardPainter.cpp @@ -195,18 +195,12 @@ void CardPainter::paint_card_back(Gfx::Bitmap& bitmap) auto paint_rect = bitmap.rect(); painter.clear_rect(paint_rect, Gfx::Color::Transparent); - auto image = Gfx::Bitmap::try_load_from_file(m_background_image_path).release_value_but_fixme_should_propagate_errors(); - - float aspect_ratio = image->width() / static_cast(image->height()); - Gfx::IntSize target_size { static_cast(aspect_ratio * (Card::height - 5)), Card::height - 5 }; - painter.fill_rect_with_rounded_corners(paint_rect, Color::Black, Card::card_radius); auto inner_paint_rect = paint_rect.shrunken(2, 2); painter.fill_rect_with_rounded_corners(inner_paint_rect, Color::White, Card::card_radius - 1); - painter.draw_scaled_bitmap( - { { (Card::width - target_size.width()) / 2, (Card::height - target_size.height()) / 2 }, target_size }, - *image, image->rect()); + auto image = Gfx::Bitmap::try_load_from_file(m_background_image_path).release_value_but_fixme_should_propagate_errors(); + painter.blit({ (bitmap.width() - image->width()) / 2, (bitmap.height() - image->height()) / 2 }, image, image->rect()); } void CardPainter::paint_inverted_card(Gfx::Bitmap& bitmap, Gfx::Bitmap const& source_to_invert)