29 if ((this->
x_boundaries_.
capacity() <
static_cast<size_t>(width + 1) && !this->x_boundaries_.try_init(width + 1)) ||
30 (this->y_boundaries_.capacity() <
static_cast<size_t>(height + 1) && !this->y_boundaries_.try_init(height + 1))) {
31 ESP_LOGW(TAG,
"No memory to draw straight into the buffer; drawing pixel by pixel");
43 for (
int x = 0;
x <= width;
x++) {
46 for (
int y = 0;
y <= height;
y++) {
56 if (
x >= x_end ||
y >= y_end)
64 const uint8_t first = big_endian ? rgb565 >> 8 : rgb565 & 0xFF;
65 const uint8_t
second = big_endian ? rgb565 & 0xFF : rgb565 >> 8;
68 for (
uint32_t row = y1; row < y2; row++) {
69 uint8_t *destination =
buffer + (row * buffer_width + x1) * 2;
70 for (
uint32_t col = x1; col < x2; col++) {
71 destination[0] = first;
83 this->
draw_rgb565_(x,
y, w,
h, display::ColorUtil::color_to_565(color));
100 x2 = std::min(buffer_width, x2);
101 y2 = std::min(buffer_height, y2);
102 for (
int i = x1; i < x2; i++) {
103 for (
int j = y1; j < y2; j++) {
void push_back(const T &value)
Add element without bounds checking Caller must ensure sufficient capacity was allocated via init() S...
bool has_transparency() const
ImageType get_type() const
FixedVector< uint16_t > x_boundaries_
void prepare_draw_(int width, int height)
Draw a source of width x height over the whole buffer from now on.
void draw_rgb565_(int x, int y, int w, int h, uint16_t rgb565)
Paint a block of source pixels in one color straight into the buffer. Only while uses_direct_rgb565()...
bool resize_image_(int width, int height)
Resize the image for a width x height source, without preparing to draw. prepare_draw_() must follow.
uint8_t * image_buffer_() const
The image's pixel buffer, for decoders that write their output straight into it.
void draw(int x, int y, int w, int h, const Color &color)
Fill a rectangle on the display_buffer using the defined color.
FixedVector< uint16_t > y_boundaries_
bool set_size(int width, int height)
Request the image to be resized once the actual dimensions are known.
bool image_is_big_endian_() const
int get_buffer_height() const
int resize(int width, int height)
Resize the image buffer to the requested dimensions.
int get_buffer_width() const
void draw_pixel(int x, int y, const Color &color)
ESPHOME_LOG_TAG(TAG, "image_decoder.bmp")
int scale_boundary(int n, int source, int target)
The first of target pixels that pixel n of source paints, rounded up: ceil(n * target / source).