mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 18:47:44 +00:00
LibGfx: Rename 32-bit bitmap StorageFormats to BGRA8888 and BGRx8888
This commit is contained in:
parent
e0f32626bc
commit
5023331726
4 changed files with 21 additions and 21 deletions
|
@ -70,11 +70,11 @@ static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::IntPoint& start_position,
|
||||||
while (!queue.is_empty()) {
|
while (!queue.is_empty()) {
|
||||||
auto position = queue.dequeue();
|
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)
|
if (color_distance_squared(pixel_color, target_color) > threshold_normalized_squared)
|
||||||
continue;
|
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)
|
if (position.x() != 0)
|
||||||
queue.enqueue(position.translated(-1, 0));
|
queue.enqueue(position.translated(-1, 0));
|
||||||
|
|
|
@ -79,7 +79,7 @@ void SprayTool::paint_it()
|
||||||
continue;
|
continue;
|
||||||
if (ypos < 0 || ypos >= bitmap.height())
|
if (ypos < 0 || ypos >= bitmap.height())
|
||||||
continue;
|
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());
|
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:
|
case StorageFormat::Indexed8:
|
||||||
element_size = 1;
|
element_size = 1;
|
||||||
break;
|
break;
|
||||||
case StorageFormat::RGB32:
|
case StorageFormat::BGRx8888:
|
||||||
case StorageFormat::RGBA32:
|
case StorageFormat::BGRA8888:
|
||||||
element_size = 4;
|
element_size = 4;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -73,17 +73,17 @@ inline bool is_valid_bitmap_format(unsigned format)
|
||||||
|
|
||||||
enum class StorageFormat {
|
enum class StorageFormat {
|
||||||
Indexed8,
|
Indexed8,
|
||||||
RGB32,
|
BGRx8888,
|
||||||
RGBA32,
|
BGRA8888,
|
||||||
};
|
};
|
||||||
|
|
||||||
static StorageFormat determine_storage_format(BitmapFormat format)
|
static StorageFormat determine_storage_format(BitmapFormat format)
|
||||||
{
|
{
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case BitmapFormat::BGRx8888:
|
case BitmapFormat::BGRx8888:
|
||||||
return StorageFormat::RGB32;
|
return StorageFormat::BGRx8888;
|
||||||
case BitmapFormat::BGRA8888:
|
case BitmapFormat::BGRA8888:
|
||||||
return StorageFormat::RGBA32;
|
return StorageFormat::BGRA8888;
|
||||||
case BitmapFormat::Indexed1:
|
case BitmapFormat::Indexed1:
|
||||||
case BitmapFormat::Indexed2:
|
case BitmapFormat::Indexed2:
|
||||||
case BitmapFormat::Indexed4:
|
case BitmapFormat::Indexed4:
|
||||||
|
@ -295,14 +295,14 @@ inline const RGBA32* Bitmap::scanline(int y) const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
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());
|
VERIFY(x >= 0 && x < physical_width());
|
||||||
return Color::from_rgb(scanline(y)[x]);
|
return Color::from_rgb(scanline(y)[x]);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
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());
|
VERIFY(x >= 0 && x < physical_width());
|
||||||
return Color::from_rgba(scanline(y)[x]);
|
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
|
inline Color Bitmap::get_pixel(int x, int y) const
|
||||||
{
|
{
|
||||||
switch (determine_storage_format(m_format)) {
|
switch (determine_storage_format(m_format)) {
|
||||||
case StorageFormat::RGB32:
|
case StorageFormat::BGRx8888:
|
||||||
return get_pixel<StorageFormat::RGB32>(x, y);
|
return get_pixel<StorageFormat::BGRx8888>(x, y);
|
||||||
case StorageFormat::RGBA32:
|
case StorageFormat::BGRA8888:
|
||||||
return get_pixel<StorageFormat::RGBA32>(x, y);
|
return get_pixel<StorageFormat::BGRA8888>(x, y);
|
||||||
case StorageFormat::Indexed8:
|
case StorageFormat::Indexed8:
|
||||||
return get_pixel<StorageFormat::Indexed8>(x, y);
|
return get_pixel<StorageFormat::Indexed8>(x, y);
|
||||||
default:
|
default:
|
||||||
|
@ -330,13 +330,13 @@ inline Color Bitmap::get_pixel(int x, int y) const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
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());
|
VERIFY(x >= 0 && x < physical_width());
|
||||||
scanline(y)[x] = color.value();
|
scanline(y)[x] = color.value();
|
||||||
}
|
}
|
||||||
template<>
|
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());
|
VERIFY(x >= 0 && x < physical_width());
|
||||||
scanline(y)[x] = color.value(); // drop alpha
|
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)
|
inline void Bitmap::set_pixel(int x, int y, Color color)
|
||||||
{
|
{
|
||||||
switch (determine_storage_format(m_format)) {
|
switch (determine_storage_format(m_format)) {
|
||||||
case StorageFormat::RGB32:
|
case StorageFormat::BGRx8888:
|
||||||
set_pixel<StorageFormat::RGB32>(x, y, color);
|
set_pixel<StorageFormat::BGRx8888>(x, y, color);
|
||||||
break;
|
break;
|
||||||
case StorageFormat::RGBA32:
|
case StorageFormat::BGRA8888:
|
||||||
set_pixel<StorageFormat::RGBA32>(x, y, color);
|
set_pixel<StorageFormat::BGRA8888>(x, y, color);
|
||||||
break;
|
break;
|
||||||
case StorageFormat::Indexed8:
|
case StorageFormat::Indexed8:
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue