9#include "TinyGPU/Font/Font5x7.h"
10#include "TinyGPU/Font/IFont.h"
11#include "TinyGPU/Surface/ISurface.h"
12#include "TinyGPU/Font/LinePrinter.h"
13#include "TinyGPU/Color/RGB565.h"
14#include "TinyGPU/Color/RGB666.h"
15#include "TinyGPU/Color/RGB888.h"
16#include "TinyGPU/Surface/SurfaceBase.h"
18#include "TinyGPU/ThreeD/Vector.h"
23
24
25
26
27
28
29
30
31
32
33
34
36template <
typename RGB_T =
RGB565>
38 static_assert(!std::is_same<RGB_T,
bool>::value,
39 "Use SurfaceMonochrome for monochrome surfaces");
60 void setPixel(size_t x, size_t y, RGB_T color)
override {
61 if (
buffer ==
nullptr)
return;
62 if (x >= width_ || y >= height_)
return;
63 buffer[(y * width_) + x] = color;
70 RGB_T
getPixel(size_t x, size_t y)
const override {
71 if (
buffer ==
nullptr)
return RGB_T();
72 if (x >= width_ || y >= height_)
return RGB_T();
73 return buffer[(y * width_) + x];
81 buffer_size = w * h *
sizeof(RGB_T);
82 assert(buffer_size <= buffer_capacity);
88 const uint8_t*
data()
const override {
89 return reinterpret_cast<
const uint8_t*>(
buffer);
98 uint8_t*
data() {
return reinterpret_cast<uint8_t*>(
buffer); }
120 buffer =
static_cast<RGB_T*>(externalBuffer) ;
121 buffer_capacity = capacityBytes;
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: SurfaceWithExternalBuffer.h:37
void setExternalBuffer(void *externalBuffer, size_t capacityBytes)
Defines the external buffer.
Definition: SurfaceWithExternalBuffer.h:119
RGB_T * pixels()
Mutable pointer to the pixel buffer, typed as RGB_T rather than raw bytes - the same buffer data() ab...
Definition: SurfaceWithExternalBuffer.h:107
size_t pixelCount() const
Number of RGB_T entries pixels()/data() has room for (width() * height()) - distinct from size(),...
Definition: SurfaceWithExternalBuffer.h:112
size_t capacity() const
Returns the capacity of the external buffer in bytes.
Definition: SurfaceWithExternalBuffer.h:125
size_t buffer_size
Definition: SurfaceWithExternalBuffer.h:129
SurfaceWithExternalBuffer()=default
Default constructor. Creates an empty surface.
const uint8_t * data() const override
Returns a pointer to the raw data as bytes.
Definition: SurfaceWithExternalBuffer.h:88
uint8_t * data()
Mutable counterpart of data() - a pointer to the raw pixel buffer as bytes, for callers that want to ...
Definition: SurfaceWithExternalBuffer.h:98
RGB_T * buffer
Definition: SurfaceWithExternalBuffer.h:128
SurfaceWithExternalBuffer(size_t w, size_t h, IFont< RGB_T > &font=FontRGB565)
Constructs a surface with the given width, height, and font.
Definition: SurfaceWithExternalBuffer.h:53
void setPixel(size_t x, size_t y, RGB_T color) override
Sets the pixel at (x, y) to the specified color.
Definition: SurfaceWithExternalBuffer.h:60
size_t size() const override
Returns the size of the buffer in bytes.
Definition: SurfaceWithExternalBuffer.h:116
bool resizeBuffer(size_t w, size_t h) override
Resizes the internal pixel buffer to the specified width and height.
Definition: SurfaceWithExternalBuffer.h:80
size_t buffer_capacity
Definition: SurfaceWithExternalBuffer.h:130
RGB_T getPixel(size_t x, size_t y) const override
Gets the color of the pixel at (x, y).
Definition: SurfaceWithExternalBuffer.h:70
Definition: DSIBusESP32.h:19