ladybird/Libraries/LibDraw/PNGLoader.h
Andreas Kling 1bd2941467 LibDraw: Add ImageLoader, a simple abstraction for image loading
An ImageLoader is a generic interface for loading encoded image data of
any supported format. It has an ImageLoaderPlugin internally that does
all the work.

This patch adds an initial PNGImageLoaderPlugin that knows how to
retrieve the size of a PNG, and the bitmap. The API is divided into
size() and bitmap() to facilitate geometry-only decoding.
This will be useful in places like LibHTML where we need dimensions for
layout purposes but can wait with the bitmap until later.
2019-10-15 21:48:08 +02:00

21 lines
537 B
C++

#pragma once
#include <LibDraw/GraphicsBitmap.h>
#include <LibDraw/ImageLoader.h>
RefPtr<GraphicsBitmap> load_png(const StringView& path);
RefPtr<GraphicsBitmap> load_png_from_memory(const u8*, size_t);
struct PNGLoadingContext;
class PNGImageLoaderPlugin final : public ImageLoaderPlugin {
public:
virtual ~PNGImageLoaderPlugin() override;
PNGImageLoaderPlugin(const u8*, size_t);
virtual Size size() override;
virtual RefPtr<GraphicsBitmap> bitmap() override;
private:
OwnPtr<PNGLoadingContext> m_context;
};