mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:17:35 +00:00
LibGfx: Make draw_tiled_bitmap() in scaled contexts actually work
This commit is contained in:
parent
d37efbe647
commit
dcc967d1ad
2 changed files with 7 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue