summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/PNGLoader.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-20 14:29:33 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-21 20:22:48 +0100
commit5a79c69b0216f070b07d8238e4c2c7e3420faeec (patch)
treea88ee6dff60c34b27f383d36a4dfd3ba4b11c482 /Userland/Libraries/LibGfx/PNGLoader.cpp
parentae7656072a403f69607109d941aa0c4b6274f60c (diff)
downloadserenity-5a79c69b0216f070b07d8238e4c2c7e3420faeec.zip
LibGfx: Make ImageDecoderPlugin::frame() return ErrorOr<>
This is a first step towards better error propagation from image codecs.
Diffstat (limited to 'Userland/Libraries/LibGfx/PNGLoader.cpp')
-rw-r--r--Userland/Libraries/LibGfx/PNGLoader.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibGfx/PNGLoader.cpp b/Userland/Libraries/LibGfx/PNGLoader.cpp
index 13220dfe53..eb0557f3ba 100644
--- a/Userland/Libraries/LibGfx/PNGLoader.cpp
+++ b/Userland/Libraries/LibGfx/PNGLoader.cpp
@@ -964,23 +964,23 @@ size_t PNGImageDecoderPlugin::frame_count()
return 1;
}
-ImageFrameDescriptor PNGImageDecoderPlugin::frame(size_t i)
+ErrorOr<ImageFrameDescriptor> PNGImageDecoderPlugin::frame(size_t index)
{
- if (i > 0)
- return {};
+ if (index > 0)
+ return Error::from_string_literal("PNGImageDecoderPlugin: Invalid frame index"sv);
if (m_context->state == PNGLoadingContext::State::Error)
- return {};
+ return Error::from_string_literal("PNGImageDecoderPlugin: Decoding failed"sv);
if (m_context->state < PNGLoadingContext::State::BitmapDecoded) {
// NOTE: This forces the chunk decoding to happen.
bool success = decode_png_bitmap(*m_context);
if (!success)
- return {};
+ return Error::from_string_literal("PNGImageDecoderPlugin: Decoding failed"sv);
}
VERIFY(m_context->bitmap);
- return { m_context->bitmap, 0 };
+ return ImageFrameDescriptor { m_context->bitmap, 0 };
}
}