10#include "roo_io/core/multipass_input_stream.h"
11#include "roo_io/core/resource.h"
12#include "roo_io/fs/filesystem.h"
13#include "roo_logging.h"
16#include "roo_io/fs/arduino/file_resource.h"
18#include "roo_io/fs/file_resource.h"
34 bool getDimensions(
const roo_io::MultipassResource& resource,
int16_t& width,
37 bool open(
const roo_io::MultipassResource& resource,
int16_t& width,
40 void draw(
const roo_io::MultipassResource& resource,
const Surface&
s,
43 void close() { input_ =
nullptr; }
45 std::unique_ptr<uint8_t[]> workspace_;
48 std::unique_ptr<roo_io::MultipassInputStream> input_;
57 : decoder_(
decoder), resource_(resource) {
58 decoder_.getDimensions(resource_, width_, height_);
61 Box extents()
const override {
return Box(0, 0, width_ - 1, height_ - 1); }
64 void drawTo(
const Surface&
s)
const override {
65 decoder_.draw(resource_,
s, 0, width_, height_);
68 JpegDecoder& decoder_;
70 roo_io::MultipassResource& resource_;
71 mutable int16_t width_;
72 mutable int16_t height_;
77class JpegFile :
public Drawable {
80 JpegFile(JpegDecoder& decoder, ::fs::FS& fs, String path)
81 : resource_(fs, path.c_str()), img_(decoder, resource_) {}
84 JpegFile(JpegDecoder& decoder, roo_io::Filesystem& fs, String path)
85 : resource_(fs, path.c_str()), img_(decoder, resource_) {}
88 JpegFile(JpegDecoder& decoder, roo_io::Filesystem& fs, std::string path)
89 : resource_(fs, std::move(path)), 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.
JPEG decoder (stateful, reusable).
friend int jpeg_draw_rect(JDEC *jdec, void *data, JRECT *rect)
friend size_t jpeg_read(JDEC *, uint8_t *, size_t)
JpegDecoder()
Construct a JPEG decoder instance.
Drawable JPEG image backed by a file resource (non-Arduino).
JpegFile(JpegDecoder &decoder, roo_io::Filesystem &fs, std::string path)
Create a JPEG file drawable using a roo_io filesystem and path.
Box extents() const override
Return the bounding box encompassing all pixels that need to be drawn.
Drawable JPEG image backed by a multipass resource.
JpegImage(JpegDecoder &decoder, roo_io::MultipassResource &resource)
Create a JPEG 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.