11 for (
int img_x = 0; img_x <
width_; img_x++) {
12 for (
int img_y = 0; img_y <
height_; img_y++) {
23 for (
int img_x = 0; img_x <
width_; img_x++) {
24 for (
int img_y = 0; img_y <
height_; img_y++) {
25 const uint32_t pos = (img_x + img_y * this->
width_);
35 auto on = (float) gray / 255.0f;
38 color =
Color(color_on.
r * on + color_off.
r * off, color_on.
g * on + color_off.
g * off,
39 color_on.
b * on + color_off.
b * off, 0xFF);
50 for (
int img_x = 0; img_x <
width_; img_x++) {
51 for (
int img_y = 0; img_y <
height_; img_y++) {
53 if (color.w >= 0x80) {
60 for (
int img_x = 0; img_x <
width_; img_x++) {
61 for (
int img_y = 0; img_y <
height_; img_y++) {
63 if (color.w >= 0x80) {
72 if (x < 0 || x >= this->
width_ || y < 0 || y >= this->
height_)
74 switch (this->
type_) {
92 if (this->
dsc_.data != this->data_start_) {
94 this->
dsc_.header.always_zero = 0;
95 this->
dsc_.header.reserved = 0;
101 this->
dsc_.header.cf = LV_IMG_CF_ALPHA_1BIT;
105 this->
dsc_.header.cf = LV_IMG_CF_ALPHA_8BIT;
109 #if LV_COLOR_DEPTH == 32 110 switch (this->transparent_) {
112 this->
dsc_.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA;
115 this->
dsc_.header.cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED;
118 this->
dsc_.header.cf = LV_IMG_CF_TRUE_COLOR;
122 this->
dsc_.header.cf =
128 #if LV_COLOR_DEPTH == 16 131 this->
dsc_.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA;
134 this->
dsc_.header.cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED;
137 this->
dsc_.header.cf = LV_IMG_CF_TRUE_COLOR;
151 const uint32_t width_8 = ((this->
width_ + 7u) / 8u) * 8u;
152 const uint32_t pos = x + y * width_8;
156 const uint32_t pos = (x + y * this->
width_) * this->
bpp_ / 8;
162 if (color.
g == 1 && color.
r == 0 && color.
b == 0) {
178 auto r = (rgb565 & 0xF800) >> 11;
179 auto g = (rgb565 & 0x07E0) >> 5;
180 auto b = rgb565 & 0x001F;
187 if (rgb565 == 0x0020)
193 return Color((r << 3) | (r >> 2), (g << 2) | (g >> 4), (b << 3) | (b >> 2), a);
197 const uint32_t pos = (x + y * this->
width_);
202 return Color(0, 0, 0, 0);
203 return Color(gray, gray, gray, 0xFF);
205 return Color(0, 0, 0, gray);
207 return Color(gray, gray, gray, 0xFF);
215 switch (this->
type_) {
ImageType get_type() const
bool get_binary_pixel_(int x, int y) const
Color get_rgb_pixel_(int x, int y) const
Color get_pixel(int x, int y, Color color_on=display::COLOR_ON, Color color_off=display::COLOR_OFF) const
Color get_grayscale_pixel_(int x, int y) const
int get_width() const override
size_t get_width_stride() const
Return the stride of the image in bytes, that is, the distance in bytes between two consecutive rows ...
Color get_rgb565_pixel_(int x, int y) const
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
const uint8_t * data_start_
lv_img_dsc_t * get_lv_img_dsc()
uint8_t progmem_read_byte(const uint8_t *addr)
Transparency transparency_
int get_height() const override
void draw(int x, int y, display::Display *display, Color color_on, Color color_off) override
void draw_pixel_at(int x, int y)
Set a single pixel at the specified coordinates to default color.
Implementation of SPI Controller mode.
Image(const uint8_t *data_start, int width, int height, ImageType type, Transparency transparency)