mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +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
1 changed files with 6 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue