16 if (clipping.is_set()) {
18 img_x0 += clipping.x -
x;
20 img_y0 += clipping.y -
y;
21 if (w > clipping.x2() -
x)
22 w = clipping.x2() -
x;
23 if (
h > clipping.y2() -
y)
24 h = clipping.y2() -
y;
29 for (
int img_x = img_x0; img_x < w; img_x++) {
30 for (
int img_y = img_y0; img_y <
h; img_y++) {
41 for (
int img_x = img_x0; img_x < w; img_x++) {
42 for (
int img_y = img_y0; img_y <
h; img_y++) {
43 const uint32_t pos = (img_x + img_y * this->
width_);
53 auto on = (float) gray / 255.0f;
56 color =
Color(color_on.
r * on + color_off.
r * off, color_on.
g * on + color_off.
g * off,
57 color_on.
b * on + color_off.
b * off, 0xFF);
68 for (
int img_x = img_x0; img_x < w; img_x++) {
69 for (
int img_y = img_y0; img_y <
h; img_y++) {
71 if (color.w >= 0x80) {
78 for (
int img_x = img_x0; img_x < w; img_x++) {
79 for (
int img_y = img_y0; img_y <
h; img_y++) {
81 if (color.w >= 0x80) {
92 switch (this->
type_) {
110 if (this->
dsc_.data != this->data_start_) {
112 this->
dsc_.header.always_zero = 0;
113 this->
dsc_.header.reserved = 0;
119 this->
dsc_.header.cf = LV_IMG_CF_ALPHA_1BIT;
123 this->
dsc_.header.cf = LV_IMG_CF_ALPHA_8BIT;
127#if LV_COLOR_DEPTH == 32
128 switch (this->transparent_) {
130 this->
dsc_.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA;
133 this->
dsc_.header.cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED;
136 this->
dsc_.header.cf = LV_IMG_CF_TRUE_COLOR;
140 this->
dsc_.header.cf =
146#if LV_COLOR_DEPTH == 16
149 this->
dsc_.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA;
152 this->
dsc_.header.cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED;
155 this->
dsc_.header.cf = LV_IMG_CF_TRUE_COLOR;
169 const uint32_t width_8 = ((this->
width_ + 7u) / 8u) * 8u;
170 const uint32_t pos =
x +
y * width_8;
174 const uint32_t pos = (
x +
y * this->
width_) * this->
bpp_ / 8;
180 if (color.
g == 1 && color.
r == 0 && color.
b == 0) {
196 auto r = (rgb565 & 0xF800) >> 11;
197 auto g = (rgb565 & 0x07E0) >> 5;
198 auto b = rgb565 & 0x001F;
205 if (rgb565 == 0x0020)
211 return Color((r << 3) | (r >> 2), (g << 2) | (g >> 4), (b << 3) | (b >> 2), a);
215 const uint32_t pos = (
x +
y * this->
width_);
220 return Color(0, 0, 0, 0);
221 return Color(gray, gray, gray, 0xFF);
223 return Color(0, 0, 0, gray);
225 return Color(gray, gray, gray, 0xFF);
232 : width_(width), height_(height), type_(
type), data_start_(data_start), transparency_(transparency) {
233 switch (this->
type_) {
void draw_pixel_at(int x, int y)
Set a single pixel at the specified coordinates to default color.
Rect get_clipping() const
Get the current the clipping rectangle.
Color get_rgb565_pixel_(int x, int y) const
const uint8_t * data_start_
Color get_rgb_pixel_(int x, int y) const
size_t get_width_stride() const
Return the stride of the image in bytes, that is, the distance in bytes between two consecutive rows ...
Image(const uint8_t *data_start, int width, int height, ImageType type, Transparency transparency)
Color get_pixel(int x, int y, Color color_on=display::COLOR_ON, Color color_off=display::COLOR_OFF) const
int get_height() const override
ImageType get_type() const
bool get_binary_pixel_(int x, int y) const
lv_img_dsc_t * get_lv_img_dsc()
Transparency transparency_
void draw(int x, int y, display::Display *display, Color color_on, Color color_off) override
int get_width() const override
Color get_grayscale_pixel_(int x, int y) const
@ TRANSPARENCY_ALPHA_CHANNEL
@ TRANSPARENCY_CHROMA_KEY
Providing packet encoding functions for exchanging data with a remote host.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
uint8_t progmem_read_byte(const uint8_t *addr)