mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
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.
This commit is contained in:
parent
653b614611
commit
96c71b7042
|
@ -20,6 +20,11 @@ struct LoadedImage {
|
||||||
Optional<ReadonlyBytes> icc_data;
|
Optional<ReadonlyBytes> icc_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static ErrorOr<LoadedImage> load_image(RefPtr<Gfx::ImageDecoder> const& decoder, int frame_index)
|
||||||
|
{
|
||||||
|
return LoadedImage { TRY(decoder->frame(frame_index)).image, TRY(decoder->icc_data()) };
|
||||||
|
}
|
||||||
|
|
||||||
static ErrorOr<void> do_move_alpha_to_rgb(LoadedImage& image)
|
static ErrorOr<void> do_move_alpha_to_rgb(LoadedImage& image)
|
||||||
{
|
{
|
||||||
auto frame = image.bitmap;
|
auto frame = image.bitmap;
|
||||||
|
@ -151,7 +156,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
if (!decoder)
|
if (!decoder)
|
||||||
return Error::from_string_view("Failed to decode input file"sv);
|
return Error::from_string_view("Failed to decode input file"sv);
|
||||||
|
|
||||||
LoadedImage image = { TRY(decoder->frame(frame_index)).image, TRY(decoder->icc_data()) };
|
LoadedImage image = TRY(load_image(*decoder, frame_index));
|
||||||
|
|
||||||
if (move_alpha_to_rgb)
|
if (move_alpha_to_rgb)
|
||||||
TRY(do_move_alpha_to_rgb(image));
|
TRY(do_move_alpha_to_rgb(image));
|
||||||
|
|
Loading…
Reference in a new issue