mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
LibGfx: Rename 32-bit bitmap StorageFormats to BGRA8888 and BGRx8888
This commit is contained in:
parent
e0f32626bc
commit
5023331726
|
@ -70,11 +70,11 @@ static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::IntPoint& start_position,
|
|||
while (!queue.is_empty()) {
|
||||
auto position = queue.dequeue();
|
||||
|
||||
auto pixel_color = bitmap.get_pixel<Gfx::StorageFormat::RGBA32>(position.x(), position.y());
|
||||
auto pixel_color = bitmap.get_pixel<Gfx::StorageFormat::BGRA8888>(position.x(), position.y());
|
||||
if (color_distance_squared(pixel_color, target_color) > threshold_normalized_squared)
|
||||
continue;
|
||||
|
||||
bitmap.set_pixel<Gfx::StorageFormat::RGBA32>(position.x(), position.y(), fill_color);
|
||||
bitmap.set_pixel<Gfx::StorageFormat::BGRA8888>(position.x(), position.y(), fill_color);
|
||||
|
||||
if (position.x() != 0)
|
||||
queue.enqueue(position.translated(-1, 0));
|
||||
|
|
|
@ -79,7 +79,7 @@ void SprayTool::paint_it()
|
|||
continue;
|
||||
if (ypos < 0 || ypos >= bitmap.height())
|
||||
continue;
|
||||
bitmap.set_pixel<Gfx::StorageFormat::RGBA32>(xpos, ypos, m_color);
|
||||
bitmap.set_pixel<Gfx::StorageFormat::BGRA8888>(xpos, ypos, m_color);
|
||||
}
|
||||
|
||||
layer->did_modify_bitmap(*m_editor->image());
|
||||
|
|
|
@ -64,8 +64,8 @@ size_t Bitmap::minimum_pitch(size_t physical_width, BitmapFormat format)
|
|||
case StorageFormat::Indexed8:
|
||||
element_size = 1;
|
||||
break;
|
||||
case StorageFormat::RGB32:
|
||||
case StorageFormat::RGBA32:
|
||||
case StorageFormat::BGRx8888:
|
||||
case StorageFormat::BGRA8888:
|
||||
element_size = 4;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -73,17 +73,17 @@ inline bool is_valid_bitmap_format(unsigned format)
|
|||
|
||||
enum class StorageFormat {
|
||||
Indexed8,
|
||||
RGB32,
|
||||
RGBA32,
|
||||
BGRx8888,
|
||||
BGRA8888,
|
||||
};
|
||||
|
||||
static StorageFormat determine_storage_format(BitmapFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case BitmapFormat::BGRx8888:
|
||||
return StorageFormat::RGB32;
|
||||
return StorageFormat::BGRx8888;
|
||||
case BitmapFormat::BGRA8888:
|
||||
return StorageFormat::RGBA32;
|
||||
return StorageFormat::BGRA8888;
|
||||
case BitmapFormat::Indexed1:
|
||||
case BitmapFormat::Indexed2:
|
||||
case BitmapFormat::Indexed4:
|
||||
|
@ -295,14 +295,14 @@ inline const RGBA32* Bitmap::scanline(int y) const
|
|||
}
|
||||
|
||||
template<>
|
||||
inline Color Bitmap::get_pixel<StorageFormat::RGB32>(int x, int y) const
|
||||
inline Color Bitmap::get_pixel<StorageFormat::BGRx8888>(int x, int y) const
|
||||
{
|
||||
VERIFY(x >= 0 && x < physical_width());
|
||||
return Color::from_rgb(scanline(y)[x]);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Color Bitmap::get_pixel<StorageFormat::RGBA32>(int x, int y) const
|
||||
inline Color Bitmap::get_pixel<StorageFormat::BGRA8888>(int x, int y) const
|
||||
{
|
||||
VERIFY(x >= 0 && x < physical_width());
|
||||
return Color::from_rgba(scanline(y)[x]);
|
||||
|
@ -318,10 +318,10 @@ inline Color Bitmap::get_pixel<StorageFormat::Indexed8>(int x, int y) const
|
|||
inline Color Bitmap::get_pixel(int x, int y) const
|
||||
{
|
||||
switch (determine_storage_format(m_format)) {
|
||||
case StorageFormat::RGB32:
|
||||
return get_pixel<StorageFormat::RGB32>(x, y);
|
||||
case StorageFormat::RGBA32:
|
||||
return get_pixel<StorageFormat::RGBA32>(x, y);
|
||||
case StorageFormat::BGRx8888:
|
||||
return get_pixel<StorageFormat::BGRx8888>(x, y);
|
||||
case StorageFormat::BGRA8888:
|
||||
return get_pixel<StorageFormat::BGRA8888>(x, y);
|
||||
case StorageFormat::Indexed8:
|
||||
return get_pixel<StorageFormat::Indexed8>(x, y);
|
||||
default:
|
||||
|
@ -330,13 +330,13 @@ inline Color Bitmap::get_pixel(int x, int y) const
|
|||
}
|
||||
|
||||
template<>
|
||||
inline void Bitmap::set_pixel<StorageFormat::RGB32>(int x, int y, Color color)
|
||||
inline void Bitmap::set_pixel<StorageFormat::BGRx8888>(int x, int y, Color color)
|
||||
{
|
||||
VERIFY(x >= 0 && x < physical_width());
|
||||
scanline(y)[x] = color.value();
|
||||
}
|
||||
template<>
|
||||
inline void Bitmap::set_pixel<StorageFormat::RGBA32>(int x, int y, Color color)
|
||||
inline void Bitmap::set_pixel<StorageFormat::BGRA8888>(int x, int y, Color color)
|
||||
{
|
||||
VERIFY(x >= 0 && x < physical_width());
|
||||
scanline(y)[x] = color.value(); // drop alpha
|
||||
|
@ -344,11 +344,11 @@ inline void Bitmap::set_pixel<StorageFormat::RGBA32>(int x, int y, Color color)
|
|||
inline void Bitmap::set_pixel(int x, int y, Color color)
|
||||
{
|
||||
switch (determine_storage_format(m_format)) {
|
||||
case StorageFormat::RGB32:
|
||||
set_pixel<StorageFormat::RGB32>(x, y, color);
|
||||
case StorageFormat::BGRx8888:
|
||||
set_pixel<StorageFormat::BGRx8888>(x, y, color);
|
||||
break;
|
||||
case StorageFormat::RGBA32:
|
||||
set_pixel<StorageFormat::RGBA32>(x, y, color);
|
||||
case StorageFormat::BGRA8888:
|
||||
set_pixel<StorageFormat::BGRA8888>(x, y, color);
|
||||
break;
|
||||
case StorageFormat::Indexed8:
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
Loading…
Reference in a new issue