diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index 5612fae972..a105ab44c7 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -66,6 +66,7 @@ size_t Bitmap::minimum_pitch(size_t physical_width, BitmapFormat format) break; case StorageFormat::BGRx8888: case StorageFormat::BGRA8888: + case StorageFormat::RGBA8888: element_size = 4; break; default: diff --git a/Userland/Libraries/LibGfx/Bitmap.h b/Userland/Libraries/LibGfx/Bitmap.h index bb8c8e78cc..53d3e58598 100644 --- a/Userland/Libraries/LibGfx/Bitmap.h +++ b/Userland/Libraries/LibGfx/Bitmap.h @@ -54,6 +54,7 @@ enum class BitmapFormat { Indexed8, BGRx8888, BGRA8888, + RGBA8888, }; inline bool is_valid_bitmap_format(unsigned format) @@ -66,6 +67,7 @@ inline bool is_valid_bitmap_format(unsigned format) case (unsigned)BitmapFormat::Indexed8: case (unsigned)BitmapFormat::BGRx8888: case (unsigned)BitmapFormat::BGRA8888: + case (unsigned)BitmapFormat::RGBA8888: return true; } return false; @@ -75,6 +77,7 @@ enum class StorageFormat { Indexed8, BGRx8888, BGRA8888, + RGBA8888, }; static StorageFormat determine_storage_format(BitmapFormat format) @@ -84,6 +87,8 @@ static StorageFormat determine_storage_format(BitmapFormat format) return StorageFormat::BGRx8888; case BitmapFormat::BGRA8888: return StorageFormat::BGRA8888; + case BitmapFormat::RGBA8888: + return StorageFormat::RGBA8888; case BitmapFormat::Indexed1: case BitmapFormat::Indexed2: case BitmapFormat::Indexed4: diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index e83c9386cf..7c94eb6d05 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -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();