10#include "TinyGPU/Font/Font5x7.h"
11#include "TinyGPU/Font/IFont.h"
12#include "TinyGPU/Surface/ISurface.h"
13#include "TinyGPU/Font/LinePrinter.h"
14#include "TinyGPU/Color/RGB565.h"
15#include "TinyGPU/Color/RGB666.h"
16#include "TinyGPU/Color/RGB888.h"
17#include "TinyGPU/Surface/SurfaceBase.h"
19#include "TinyGPU/ThreeD/Vector.h"
24
25
26
27
28
29
30
31
32
33
34
35
37template <
typename RGB_T =
RGB565>
39 static_assert(!std::is_same<RGB_T,
bool>::value,
40 "Use SurfaceMonochrome for monochrome surfaces");
61 void setPixel(size_t x, size_t y, RGB_T color)
override {
62 if (buffer.empty())
return;
63 if (x >= width_ || y >= height_)
return;
64 buffer[(y * width_) + x] = color;
71 RGB_T
getPixel(size_t x, size_t y)
const override {
72 if (buffer.empty())
return RGB_T();
73 if (x >= width_ || y >= height_)
return RGB_T();
74 return buffer[(y * width_) + x];
83 return buffer.size() == (w * h) || (w * h == 0 && buffer.empty());
88 const uint8_t*
data()
const override {
89 return reinterpret_cast<
const uint8_t*>(buffer.data());
98 uint8_t*
data() {
return reinterpret_cast<uint8_t*>(buffer.data()); }
107 RGB_T*
pixels() {
return buffer.data(); }
116 size_t size()
const override {
return buffer.size() * RGB_T::size() / 8; }
123template <
typename RGB_T =
RGB565>
Font rendering interface for TinyGPU-compatible framebuffers.
Definition: IFont.h:19
RGB color stored in 16-bit RGB565 format, byte-swapped from the conventional bit layout.
Definition: RGB565.h:24
Base class for 2D surfaces with drawing and text rendering support.
Definition: SurfaceBase.h:25
In-memory bitmap surface with basic 2D drawing and text rendering.
Definition: Surface.h:38
RGB_T * pixels()
Mutable pointer to the pixel buffer, typed as RGB_T rather than raw bytes - the same buffer data() ab...
Definition: Surface.h:107
size_t pixelCount() const
Number of RGB_T entries pixels()/data() has room for (width() * height()) - distinct from size(),...
Definition: Surface.h:112
Surface()=default
Default constructor. Creates an empty surface.
Surface(size_t w, size_t h, IFont< RGB_T > &font)
Constructs a surface with the given width, height, and font.
Definition: Surface.h:54
const uint8_t * data() const override
Returns a pointer to the raw data as bytes.
Definition: Surface.h:88
uint8_t * data()
Mutable counterpart of data() - a pointer to the raw pixel buffer as bytes, for callers that want to ...
Definition: Surface.h:98
void setPixel(size_t x, size_t y, RGB_T color) override
Sets the pixel at (x, y) to the specified color.
Definition: Surface.h:61
size_t size() const override
Returns the size of the buffer in bytes.
Definition: Surface.h:116
bool resizeBuffer(size_t w, size_t h) override
Resizes the internal pixel buffer to the specified width and height.
Definition: Surface.h:81
RGB_T getPixel(size_t x, size_t y) const override
Gets the color of the pixel at (x, y).
Definition: Surface.h:71
Vector< RGB_T > buffer
Definition: Surface.h:119
Definition: DSIBusESP32.h:19