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:
parent
ae7656072a
commit
5a79c69b02
26 changed files with 101 additions and 100 deletions
|
@ -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 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue