displayign images works with some dim

This commit is contained in:
2026-02-05 10:09:00 +01:00
parent cddc24e147
commit 7136ae7385
3 changed files with 48 additions and 20 deletions
+25 -6
View File
@@ -133,15 +133,21 @@ void scrollAllScrollableTexts(bool split_scroll_mode = false)
}
}
void drawImageFromMemoryByIndex(unsigned char image_index, short pos_x, short pos_y)
void drawImageFromMemoryByIndex(unsigned char image_index, short pos_x, short pos_y, unsigned char dim_percentage = 0)
{
Image* img = &saved_images[image_index];
auto dimBy = [dim_percentage](unsigned char color)
{
return color * (100 - dim_percentage) / 100;
};
for (unsigned char y = 0; y < img->height; y++)
{
for (unsigned char x = 0; x < img->width; x++)
{
setPixel(x + pos_x, y + pos_y, pixels.Color(img->pixels[y][x].r, img->pixels[y][x].g, img->pixels[y][x].b));
}
for (unsigned char x = 0; x < img->width; x++)
{
setPixel(x + pos_x, y + pos_y, pixels.Color(dimBy(img->pixels[y][x].r), dimBy(img->pixels[y][x].g), dimBy(img->pixels[y][x].b)));
}
}
}
@@ -164,6 +170,19 @@ void loop()
{
pixels.clear();
handle_server();
scrollAllScrollableTexts();
if (saved_images[0].width > 0)
{
drawImageFromMemoryByIndex(0, 0, 0);
}
else
{
if (text_nodes[0].is_deleted && text_nodes[2].is_deleted)
{
}
scrollAllScrollableTexts();
}
pixels.show();
}