feat: pixel-perfect image and gif support for G835L and proper test written

This commit is contained in:
Ghoul
2026-01-21 23:52:53 +05:00
parent 9ee154cd1c
commit c08355f5c2
6 changed files with 207 additions and 83 deletions

View File

@@ -387,6 +387,11 @@ impl AnimeDiagonal {
/// G835L diagonal packing - inverted geometry (rows grow then constant)
/// Triangle (rows 0-27): pairs grow from 1→14 LEDs
/// Rectangle (rows 28-67): constant 15 LEDs
///
/// Diagonal PNG layout for G835L:
/// - Image height = 34 (row pairs)
/// - Image width = 68 (half-step X grid)
/// - Even/odd rows are interleaved in X (staggered by 0.5 LED = 1 px)
fn to_g835l_packets(&self) -> Result<AnimeDataBuffer> {
use log::debug;
@@ -409,15 +414,25 @@ impl AnimeDiagonal {
}
}
// Helper: starting X (in LED units) for the row
fn first_x(row: usize) -> usize {
if row < 28 {
0
} else {
(row - 28) / 2
}
}
// Process all 68 rows
for row in 0..68 {
let len = row_length(row);
let img_y = row / 2;
let base_x = first_x(row);
let stagger = row % 2;
for i in 0..len {
// Simple horizontal reading for now - each row pair reads from same image row
// Row 0,1 → img row 0; Row 2,3 → img row 1; etc.
let img_y = row / 2;
let img_x = i;
// Half-step X grid: even rows on even pixels, odd rows on odd pixels.
let img_x = (base_x + i) * 2 + stagger;
// Read from image, clamp to bounds
let val = if img_y < self.1.len() && img_x < self.1[img_y].len() {

View File

@@ -141,7 +141,7 @@ impl AnimeImage {
AnimeType::GA401 => 0.3,
AnimeType::GU604 => 0.28,
// TODO: Calculate correct values for G635L and G835L.
// Known values for G835L W*H is 34*68
// Known values for G835L diagonal W*H is 68*34
AnimeType::G635L => 0.28,
AnimeType::G835L => 0.28,
_ => 0.283,