1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:27:35 +00:00

LibGfx/PortableFormat: Extract header reading in its own function

This commit is contained in:
Lucas CHOLLET 2023-07-10 16:29:16 -04:00 committed by Sam Atkins
parent e72293fbc7
commit f6ce06d56b

View file

@ -175,12 +175,9 @@ static ErrorOr<void> create_bitmap(TContext& context)
return {};
}
template<typename TContext>
static ErrorOr<void> decode(TContext& context)
template<typename Context>
static ErrorOr<void> read_header(Context& context)
{
if (context.state >= TContext::State::Decoded)
return {};
TRY(read_magic_number(context));
TRY(read_whitespace(context));
@ -201,6 +198,16 @@ static ErrorOr<void> decode(TContext& context)
TRY(read_whitespace(context));
}
return {};
}
template<typename TContext>
static ErrorOr<void> decode(TContext& context)
{
if (context.state >= TContext::State::Decoded)
return {};
TRY(read_header(context));
TRY(read_image_data(context));
context.state = TContext::State::Decoded;