Fixed color rendering for good

This commit was merged in pull request #26.
This commit is contained in:
2026-08-22 00:29:10 +02:00
parent 8fd3de2ab7
commit cf6c068394
12 changed files with 213 additions and 234 deletions
+1 -7
View File
@@ -1,5 +1,4 @@
use crate::card::model::Palette;
use crate::display::palette::Rgb;
use embedded_graphics::{
geometry::Size, pixelcolor::Rgb565, pixelcolor::RgbColor, prelude::Point, primitives::Rectangle,
};
@@ -14,11 +13,6 @@ where
return;
}
// OPTIMIZATION 1: Pre-compute the 16-color palette to Rgb565 once.
let mut palette565 = [Rgb565::new(0, 0, 0); 16];
for (i, c) in palette.iter().enumerate() {
palette565[i] = Rgb565::new(c.r() >> 3, c.g() >> 2, c.b() >> 3);
}
let mut src_width = 1usize;
while src_width * src_width < pixel_count {
@@ -44,7 +38,7 @@ where
pixel_byte & 0x0F
};
let color = palette565[color_index as usize];
let color = palette[color_index as usize];
let start_x = (x * scale) as i32;
let start_y = (y * scale) as i32;