mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +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
Notes:
sideshowbarker
2024-07-16 23:44:30 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/96c71b7042 Pull-request: https://github.com/SerenityOS/serenity/pull/22922 Reviewed-by: https://github.com/LucasChollet ✅
1 changed files with 6 additions and 1 deletions
|
@ -20,6 +20,11 @@ struct LoadedImage {
|
|||
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)
|
||||
{
|
||||
auto frame = image.bitmap;
|
||||
|
@ -151,7 +156,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (!decoder)
|
||||
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)
|
||||
TRY(do_move_alpha_to_rgb(image));
|
||||
|
|
Loading…
Reference in a new issue