From 36bbf12b73b220a03f6aa1e4c2bf16ce4743ac99 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 28 Feb 2024 08:53:40 -0500 Subject: [PATCH] LibGfx: Add FourCC::from_u32() --- Userland/Libraries/LibGfx/FourCC.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Userland/Libraries/LibGfx/FourCC.h b/Userland/Libraries/LibGfx/FourCC.h index e26f59042b..54c06e5894 100644 --- a/Userland/Libraries/LibGfx/FourCC.h +++ b/Userland/Libraries/LibGfx/FourCC.h @@ -21,6 +21,16 @@ struct [[gnu::packed]] FourCC { cc[3] = name[3]; } + static constexpr FourCC from_u32(u32 value) + { + FourCC result; + result.cc[0] = static_cast(value >> 24); + result.cc[1] = static_cast(value >> 16); + result.cc[2] = static_cast(value >> 8); + result.cc[3] = static_cast(value); + return result; + } + bool operator==(FourCC const&) const = default; bool operator!=(FourCC const&) const = default;