From ffb23098783483333f28e3bb50a133798cbac565 Mon Sep 17 00:00:00 2001 From: liamHowatt Date: Tue, 23 Jul 2024 11:21:34 -0400 Subject: [PATCH] correct bit truncation --- lib/convert.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/convert.ts b/lib/convert.ts index b47b0c0..1c3a4cc 100644 --- a/lib/convert.ts +++ b/lib/convert.ts @@ -225,10 +225,8 @@ const lv_image_dsc_t ${out_name} = { } classify_pixel(value, bits) { - const tmp = 1 << (8 - bits); - let val = Math.round(value / tmp) * tmp; - if(val < 0) val = 0; - return val; + const shift = 8 - bits; + return value >> shift << shift; } format_to_c_array() {