mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:47:44 +00:00
LibGfx: Use common class template for PBM/PGM/PPM image loaders
PBM, PGM, and PPM image loaders are mostly common. The only difference is how the data is read and the associated magic numbers. The magic numbers are already made common using the loading contexts. Now make the implementations common via a class template which accepts the context to disambiguate.
This commit is contained in:
parent
786b02730c
commit
6a23dfbc92
7 changed files with 123 additions and 327 deletions
|
@ -21,26 +21,7 @@ struct PGM {
|
|||
};
|
||||
|
||||
using PGMLoadingContext = PortableImageMapLoadingContext<PGM>;
|
||||
using PGMImageDecoderPlugin = PortableImageDecoderPlugin<PGMLoadingContext>;
|
||||
|
||||
class PGMImageDecoderPlugin final : public ImageDecoderPlugin {
|
||||
public:
|
||||
PGMImageDecoderPlugin(const u8*, size_t);
|
||||
virtual ~PGMImageDecoderPlugin() override;
|
||||
|
||||
virtual IntSize size() override;
|
||||
|
||||
virtual void set_volatile() override;
|
||||
[[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;
|
||||
|
||||
virtual bool sniff() override;
|
||||
|
||||
virtual bool is_animated() override;
|
||||
virtual size_t loop_count() override;
|
||||
virtual size_t frame_count() override;
|
||||
virtual ErrorOr<ImageFrameDescriptor> frame(size_t index) override;
|
||||
|
||||
private:
|
||||
OwnPtr<PGMLoadingContext> m_context;
|
||||
};
|
||||
|
||||
bool read_image_data(PGMLoadingContext& context, Streamer& streamer);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue