5#include "roo_display/image/png/lib/png.inl"
45 switch (
pDraw->iPixelType) {
48 (
const roo::byte *)
pDraw->pPixels);
59 (
const roo::byte *)
pDraw->pPixels);
65 (
const roo::byte *)
pDraw->pPixels);
70 switch (
pDraw->iBpp) {
73 (
const roo::byte *)
pDraw->pPixels,
80 (
const roo::byte *)
pDraw->pPixels,
87 (
const roo::byte *)
pDraw->pPixels,
94 (
const roo::byte *)
pDraw->pPixels,
106bool PngDecoder::getDimensions(
const roo_io::MultipassResource &resource,
108 if (!open(resource, width, height)) {
117bool PngDecoder::open(
const roo_io::MultipassResource &resource, int16_t &width,
119 input_ = resource.open();
120 if (input_ ==
nullptr)
return false;
125 pngdec_->pfnOpen =
nullptr;
126 pngdec_->pfnClose =
nullptr;
127 pngdec_->PNGFile.iSize = input_->size();
129 pngdec_->PNGFile.fHandle =
this;
131 width = pngdec_->iWidth;
132 height = pngdec_->iHeight;
136void PngDecoder::draw(
const roo_io::MultipassResource &resource,
137 const Surface &s, uint8_t scale, int16_t &width,
139 PauseOutput pause(s.out());
140 if (!open(resource, width, height)) {
143 Box extents(0, 0, pngdec_->iWidth - 1, pngdec_->iHeight - 1);
144 if (
Box::Intersect(s.clip_box(), extents.translate(s.dx(), s.dy())).empty()) {
152 User user{.surface = &s, .palette = &palette_};
153 DecodePNG(pngdec_.get(), (
void *)&user, 0);
@ PNG_PIXEL_TRUECOLOR_ALPHA
Axis-aligned integer rectangle.
int16_t yMax() const
Maximum y (inclusive).
static Box Intersect(const Box &a, const Box &b)
Return the intersection of two boxes (may be empty).
int16_t yMin() const
Minimum y (inclusive).
static Palette ReadOnly(const Color *colors, int size)
Create a read-only palette backed by the given colors.
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)
Resumes a paused output transaction.
Low-level handle used to draw to an underlying device.
int16_t dy() const
Return the y offset to apply to drawn objects.
const Box & clip_box() const
Return the clip box in device coordinates (independent of offsets).
void drawObject(const Drawable &object) const
Draw a drawable object to this surface.
DisplayOutput & out() const
Return the device output.
Defines 140 opaque HTML named colors.
internal::Indexed< 2 > Indexed2
internal::Indexed< 1 > Indexed1
internal::Indexed< 8 > Indexed8
int32_t png_seek(PNGFILE *pFile, int32_t iPosition)
int32_t png_read(PNGFILE *pFile, uint8_t *pBuf, int32_t iLen)
void png_draw(PNGDRAW *pDraw)
internal::Indexed< 4 > Indexed4
PNG_STATIC int PNGInit(PNGIMAGE *pPNG)
PNG_STATIC int DecodePNG(PNGIMAGE *pImage, void *pUser, int iOptions)
Public API surface for roo_display display, touch, and drawing utilities.