1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:17:35 +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

@ -1354,19 +1354,19 @@ size_t BMPImageDecoderPlugin::frame_count()
return 1;
}
ImageFrameDescriptor BMPImageDecoderPlugin::frame(size_t i)
ErrorOr<ImageFrameDescriptor> BMPImageDecoderPlugin::frame(size_t index)
{
if (i > 0)
return {};
if (index > 0)
return Error::from_string_literal("BMPImageDecoderPlugin: Invalid frame index"sv);
if (m_context->state == BMPLoadingContext::State::Error)
return {};
return Error::from_string_literal("BMPImageDecoderPlugin: Decoding failed"sv);
if (m_context->state < BMPLoadingContext::State::PixelDataDecoded && !decode_bmp_pixel_data(*m_context))
return {};
return Error::from_string_literal("BMPImageDecoderPlugin: Decoding failed"sv);
VERIFY(m_context->bitmap);
return { m_context->bitmap, 0 };
return ImageFrameDescriptor { m_context->bitmap, 0 };
}
}