1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:27:46 +00:00

LibGfx: Add BitmapFormat::RGBA8888

This will be used by ImageData objects in LibWeb since the web spec
says these store colors in RGBA8888 order.

The only thing you can do with this format right now is blitting it
onto a BGRA8888 bitmap.
This commit is contained in:
Andreas Kling 2021-03-16 12:09:15 +01:00
parent 5023331726
commit fe861512c8
3 changed files with 23 additions and 0 deletions

View file

@ -770,6 +770,23 @@ void Painter::blit(const IntPoint& position, const Gfx::Bitmap& source, const In
return;
}
if (source.format() == BitmapFormat::RGBA8888) {
const u32* src = source.scanline(src_rect.top() + first_row) + src_rect.left() + first_column;
const size_t src_skip = source.pitch() / sizeof(u32);
for (int row = first_row; row <= last_row; ++row) {
for (int i = 0; i < clipped_rect.width(); ++i) {
u32 rgba = src[i];
u32 bgra = (rgba & 0xff00ff00)
| ((rgba & 0x000000ff) << 16)
| ((rgba & 0x00ff0000) >> 16);
dst[i] = bgra;
}
dst += dst_skip;
src += src_skip;
}
return;
}
if (Bitmap::is_indexed(source.format())) {
const u8* src = source.scanline_u8(src_rect.top() + first_row) + src_rect.left() + first_column;
const size_t src_skip = source.pitch();