1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:58:11 +00:00

LibGfx: Make ImageDecoderPlugin::frame() return ErrorOr<>

This is a first step towards better error propagation from image codecs.
This commit is contained in:
Andreas Kling 2021-11-20 14:29:33 +01:00
parent ae7656072a
commit 5a79c69b02
26 changed files with 101 additions and 100 deletions

View file

@ -52,12 +52,12 @@ Messages::ImageDecoderServer::DecodeImageResponse ClientConnection::decode_image
Vector<Gfx::ShareableBitmap> bitmaps;
Vector<u32> durations;
for (size_t i = 0; i < decoder->frame_count(); ++i) {
auto frame = decoder->frame(i);
if (frame.image)
bitmaps.append(frame.image->to_shareable_bitmap());
else
auto frame_or_error = decoder->frame(i);
if (frame_or_error.is_error() || !frame_or_error.value().image)
bitmaps.append(Gfx::ShareableBitmap {});
durations.append(frame.duration);
else
bitmaps.append(frame_or_error.value().image->to_shareable_bitmap());
durations.append(frame_or_error.value().duration);
}
return { decoder->is_animated(), static_cast<u32>(decoder->loop_count()), bitmaps, durations };