mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 02:03:06 -05:00
1bd2941467
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.
21 lines
537 B
C++
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;
|
|
};
|