mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
LibGfx: Support missing pixel formats in get_pixel()
Bitmap::get_pixel() was only handling two out of the four possible pixel formats, asserting when called with the other two. The asserting code path was triggered when loading JPEG XL images, causing crashes on pages like https://jpegxl.info/resources/jpeg-xl-test-page or https://html5test.co/.
This commit is contained in:
parent
f1d79483b7
commit
578a3af87d
Notes:
github-actions[bot]
2025-04-23 07:31:25 +00:00
Author: https://github.com/InvalidUsernameException
Commit: 578a3af87d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4404
Reviewed-by: https://github.com/gmta ✅
11 changed files with 92 additions and 0 deletions
|
@ -244,6 +244,18 @@ ALWAYS_INLINE Color Bitmap::unchecked_get_pixel<StorageFormat::BGRA8888>(int x,
|
|||
return Color::from_argb(unchecked_scanline(y)[x]);
|
||||
}
|
||||
|
||||
template<>
|
||||
ALWAYS_INLINE Color Bitmap::unchecked_get_pixel<StorageFormat::RGBx8888>(int x, int y) const
|
||||
{
|
||||
return Color::from_bgr(unchecked_scanline(y)[x]);
|
||||
}
|
||||
|
||||
template<>
|
||||
ALWAYS_INLINE Color Bitmap::unchecked_get_pixel<StorageFormat::RGBA8888>(int x, int y) const
|
||||
{
|
||||
return Color::from_abgr(unchecked_scanline(y)[x]);
|
||||
}
|
||||
|
||||
template<StorageFormat storage_format>
|
||||
ALWAYS_INLINE Color Bitmap::get_pixel(int x, int y) const
|
||||
{
|
||||
|
@ -259,6 +271,10 @@ ALWAYS_INLINE Color Bitmap::get_pixel(int x, int y) const
|
|||
return get_pixel<StorageFormat::BGRx8888>(x, y);
|
||||
case StorageFormat::BGRA8888:
|
||||
return get_pixel<StorageFormat::BGRA8888>(x, y);
|
||||
case StorageFormat::RGBA8888:
|
||||
return get_pixel<StorageFormat::RGBA8888>(x, y);
|
||||
case StorageFormat::RGBx8888:
|
||||
return get_pixel<StorageFormat::RGBx8888>(x, y);
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -95,6 +95,12 @@ public:
|
|||
|
||||
static constexpr Color from_rgb(unsigned rgb) { return Color(rgb | 0xff000000); }
|
||||
static constexpr Color from_argb(unsigned argb) { return Color(argb); }
|
||||
static constexpr Color from_abgr(unsigned abgr)
|
||||
{
|
||||
unsigned argb = (abgr & 0xff00ff00) | ((abgr & 0xff0000) >> 16) | ((abgr & 0xff) << 16);
|
||||
return Color::from_argb(argb);
|
||||
}
|
||||
static constexpr Color from_bgr(unsigned bgr) { return Color::from_abgr(bgr | 0xff000000); }
|
||||
|
||||
static constexpr Color from_yuv(YUV const& yuv) { return from_yuv(yuv.y, yuv.u, yuv.v); }
|
||||
static constexpr Color from_yuv(float y, float u, float v)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue