10#include "roo_io/core/multipass_input_stream.h"
13#include "roo_io/fs/arduino/file_resource.h"
15#include "roo_io/fs/file_resource.h"
31 bool getDimensions(
const roo_io::MultipassResource& resource,
int16_t& width,
34 bool open(
const roo_io::MultipassResource& resource,
int16_t& width,
37 void draw(
const roo_io::MultipassResource& resource,
const Surface&
s,
40 void close() { input_ =
nullptr; }
42 std::unique_ptr<PNGIMAGE> pngdec_;
44 std::unique_ptr<roo_io::MultipassInputStream> input_;
55 : decoder_(
decoder), resource_(resource) {
56 decoder_.getDimensions(resource_, width_, height_);
59 Box extents()
const override {
return Box(0, 0, width_ - 1, height_ - 1); }
62 void drawTo(
const Surface&
s)
const override {
65 decoder_.draw(resource_,
s, 0, width_, height_);
70 roo_io::MultipassResource& resource_;
71 mutable int16_t width_;
72 mutable int16_t height_;
77class PngFile :
public Drawable {
80 PngFile(PngDecoder& decoder, ::fs::FS& fs, String path)
81 : resource_(fs, path.c_str()), img_(decoder, resource_) {}
84 PngFile(PngDecoder& decoder, roo_io::Filesystem& fs, String path)
85 : resource_(fs, path.c_str()), img_(decoder, resource_) {}
88 PngFile(PngDecoder& decoder, roo_io::Filesystem& fs, std::string path)
89 : resource_(fs, path.c_str()), img_(decoder, resource_) {}
94 void drawTo(
const Surface& s)
const override { s.drawObject(img_); }
96 roo_io::ExtendedArduinoFileResource resource_;
110 void drawTo(
const Surface&
s)
const override {
s.drawObject(img_); }
112 roo_io::FileResource resource_;
Axis-aligned integer rectangle.
Interface for objects that can be drawn to an output device.
Palette storage for IndexedN color modes.
PNG decoder (stateful, reusable).
PngDecoder()
Construct a PNG decoder instance.
friend int32_t png_seek(PNGFILE *pFile, int32_t iPosition)
friend int32_t png_read(PNGFILE *pFile, uint8_t *pBuf, int32_t iLen)
Drawable PNG image backed by a file resource (non-Arduino).
Box extents() const override
Return the bounding box encompassing all pixels that need to be drawn.
PngFile(PngDecoder &decoder, roo_io::Filesystem &fs, std::string path)
Create a PNG file drawable using a roo_io filesystem and path.
Drawable PNG image backed by a multipass resource.
PngImage(PngDecoder &decoder, roo_io::MultipassResource &resource)
Create a PNG image using a decoder and resource.
Box extents() const override
Return the bounding box encompassing all pixels that need to be drawn.
Low-level handle used to draw to an underlying device.
Defines 140 opaque HTML named colors.
Public API surface for roo_display display, touch, and drawing utilities.