summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/PPMLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibGfx/PPMLoader.cpp')
-rw-r--r--Userland/Libraries/LibGfx/PPMLoader.cpp89
1 files changed, 1 insertions, 88 deletions
diff --git a/Userland/Libraries/LibGfx/PPMLoader.cpp b/Userland/Libraries/LibGfx/PPMLoader.cpp
index 9429869048..720cc7a5e7 100644
--- a/Userland/Libraries/LibGfx/PPMLoader.cpp
+++ b/Userland/Libraries/LibGfx/PPMLoader.cpp
@@ -16,7 +16,7 @@
namespace Gfx {
-static bool read_image_data(PPMLoadingContext& context, Streamer& streamer)
+bool read_image_data(PPMLoadingContext& context, Streamer& streamer)
{
Vector<Gfx::Color> color_data;
color_data.ensure_capacity(context.width * context.height);
@@ -69,91 +69,4 @@ static bool read_image_data(PPMLoadingContext& context, Streamer& streamer)
context.state = PPMLoadingContext::State::Bitmap;
return true;
}
-
-PPMImageDecoderPlugin::PPMImageDecoderPlugin(const u8* data, size_t size)
-{
- m_context = make<PPMLoadingContext>();
- m_context->data = data;
- m_context->data_size = size;
-}
-
-PPMImageDecoderPlugin::~PPMImageDecoderPlugin()
-{
-}
-
-IntSize PPMImageDecoderPlugin::size()
-{
- if (m_context->state == PPMLoadingContext::State::Error)
- return {};
-
- if (m_context->state < PPMLoadingContext::State::Decoded) {
- bool success = decode(*m_context);
- if (!success)
- return {};
- }
-
- return { m_context->width, m_context->height };
-}
-
-void PPMImageDecoderPlugin::set_volatile()
-{
- if (m_context->bitmap)
- m_context->bitmap->set_volatile();
-}
-
-bool PPMImageDecoderPlugin::set_nonvolatile(bool& was_purged)
-{
- if (!m_context->bitmap)
- return false;
-
- return m_context->bitmap->set_nonvolatile(was_purged);
-}
-
-bool PPMImageDecoderPlugin::sniff()
-{
- if (m_context->data_size < 2)
- return false;
-
- if (m_context->data[0] == 'P' && m_context->data[1] == '3')
- return true;
-
- if (m_context->data[0] == 'P' && m_context->data[1] == '6')
- return true;
-
- return false;
-}
-
-bool PPMImageDecoderPlugin::is_animated()
-{
- return false;
-}
-
-size_t PPMImageDecoderPlugin::loop_count()
-{
- return 0;
-}
-
-size_t PPMImageDecoderPlugin::frame_count()
-{
- return 1;
-}
-
-ErrorOr<ImageFrameDescriptor> PPMImageDecoderPlugin::frame(size_t index)
-{
- if (index > 0)
- return Error::from_string_literal("PPMImageDecoderPlugin: Invalid frame index"sv);
-
- if (m_context->state == PPMLoadingContext::State::Error)
- return Error::from_string_literal("PGMImageDecoderPlugin: Decoding failed"sv);
-
- if (m_context->state < PPMLoadingContext::State::Decoded) {
- bool success = decode(*m_context);
- if (!success)
- return Error::from_string_literal("PGMImageDecoderPlugin: Decoding failed"sv);
- }
-
- VERIFY(m_context->bitmap);
- return ImageFrameDescriptor { m_context->bitmap, 0 };
-}
-
}