Skip to content

Commit

Permalink
correct bit truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
liamHowatt committed Jul 23, 2024
1 parent 80ed17a commit ffb2309
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit ffb2309

Please sign in to comment.