From 294217586bea9276e9865810af75de557b3b9224 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Fri, 14 Jul 2023 17:50:01 -0400 Subject: [PATCH] LibGfx/GIF: Move the code to read the header to its own function By header, I include the logical screen descriptor here, so all the information that is not specific to each frame. --- Userland/Libraries/LibGfx/ImageFormats/GIFLoader.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/GIFLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/GIFLoader.cpp index 165755630f..f110b1fb57 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/GIFLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/GIFLoader.cpp @@ -381,7 +381,7 @@ static ErrorOr decode_frame(GIFLoadingContext& context, size_t frame_index return {}; } -static ErrorOr load_gif_frame_descriptors(GIFLoadingContext& context) +static ErrorOr load_header_and_logical_screen(GIFLoadingContext& context) { if (TRY(context.stream.size()) < 32) return Error::from_string_literal("Size too short for GIF frame descriptors"); @@ -412,6 +412,13 @@ static ErrorOr load_gif_frame_descriptors(GIFLoadingContext& context) context.logical_screen.color_map[i] = { r, g, b }; } + return {}; +} + +static ErrorOr load_gif_frame_descriptors(GIFLoadingContext& context) +{ + TRY(load_header_and_logical_screen(context)); + NonnullOwnPtr current_image = make(); for (;;) { u8 sentinel = TRY(context.stream.read_value());