diff --git a/Userland/Demos/LibGfxScaleDemo/main.cpp b/Userland/Demos/LibGfxScaleDemo/main.cpp index 72a7c6885a..ac11a2fa15 100644 --- a/Userland/Demos/LibGfxScaleDemo/main.cpp +++ b/Userland/Demos/LibGfxScaleDemo/main.cpp @@ -102,6 +102,8 @@ void Canvas::draw(Gfx::Painter& painter) painter.blit({ 25, 39 }, *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 }); + + painter.draw_tiled_bitmap({ 25, 60, WIDTH - 50, 40 }, *buggie); } int main(int argc, char** argv) diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index 11447f7595..bab4937eca 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -619,20 +619,20 @@ void Painter::draw_tiled_bitmap(const IntRect& a_dst_rect, const Gfx::Bitmap& so if (source.format() == BitmapFormat::RGB32 || source.format() == BitmapFormat::RGBA32) { int s = scale / source.scale(); if (s == 1) { - int x_start = first_column + a_dst_rect.left(); + int x_start = first_column + a_dst_rect.left() * scale; for (int row = first_row; row <= last_row; ++row) { - const RGBA32* sl = source.scanline((row + a_dst_rect.top()) % source.physical_height()); + const RGBA32* sl = source.scanline((row + a_dst_rect.top() * scale) % source.physical_height()); for (int x = x_start; x < clipped_rect.width() + x_start; ++x) { dst[x - x_start] = sl[x % source.physical_width()]; } dst += dst_skip; } } else { - int x_start = first_column + a_dst_rect.left(); + int x_start = first_column + a_dst_rect.left() * scale; for (int row = first_row; row <= last_row; ++row) { - const RGBA32* sl = source.scanline(((row + a_dst_rect.top()) / s) % source.height()); + const RGBA32* sl = source.scanline(((row + a_dst_rect.top() * scale) / s) % source.physical_height()); for (int x = x_start; x < clipped_rect.width() + x_start; ++x) { - dst[x - x_start] = sl[(x / s) % source.width()]; + dst[x - x_start] = sl[(x / s) % source.physical_width()]; } dst += dst_skip; }