Skip to content

Commit 96c71b7

Browse files
nicoawesomekling
authored andcommitted
image: Move image loading code into a separate function
Haters will say this is overkill, but this function will do a bit more once we allow loading CMYK data. No behavior change.
1 parent 653b614 commit 96c71b7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Userland/Utilities/image.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ struct LoadedImage {
2020
Optional<ReadonlyBytes> icc_data;
2121
};
2222

23+
static ErrorOr<LoadedImage> load_image(RefPtr<Gfx::ImageDecoder> const& decoder, int frame_index)
24+
{
25+
return LoadedImage { TRY(decoder->frame(frame_index)).image, TRY(decoder->icc_data()) };
26+
}
27+
2328
static ErrorOr<void> do_move_alpha_to_rgb(LoadedImage& image)
2429
{
2530
auto frame = image.bitmap;
@@ -151,7 +156,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
151156
if (!decoder)
152157
return Error::from_string_view("Failed to decode input file"sv);
153158

154-
LoadedImage image = { TRY(decoder->frame(frame_index)).image, TRY(decoder->icc_data()) };
159+
LoadedImage image = TRY(load_image(*decoder, frame_index));
155160

156161
if (move_alpha_to_rgb)
157162
TRY(do_move_alpha_to_rgb(image));

0 commit comments

Comments
 (0)