diff --git a/src/resources/lv_img_conv.py b/src/resources/lv_img_conv.py index 8161fe1f36..04765462ee 100755 --- a/src/resources/lv_img_conv.py +++ b/src/resources/lv_img_conv.py @@ -107,10 +107,7 @@ def main(): for x in range(img_width): i = (y*img_width + x)*4 # buffer-index pixel = img.getpixel((x,y)) - r = pixel[0] - g = pixel[1] - b = pixel[2] - a = pixel[3] + r, g, b, a = pixel buf[i + 0] = r buf[i + 1] = g buf[i + 2] = b @@ -126,12 +123,9 @@ def main(): g_act = classify_pixel(pixel[1], 6) b_act = classify_pixel(pixel[2], 5) a = pixel[3] - if r_act > 0xF8: - r_act = 0xF8 - if g_act > 0xFC: - g_act = 0xFC - if b_act > 0xF8: - b_act = 0xF8 + r_act = min(r_act, 0xF8) + g_act = min(g_act, 0xFC) + b_act = min(b_act, 0xF8) c16 = ((r_act) << 8) | ((g_act) << 3) | ((b_act) >> 3) # RGR565 buf[i + 0] = (c16 >> 8) & 0xFF buf[i + 1] = c16 & 0xFF @@ -148,17 +142,15 @@ def main(): for x in range(img_width): c, a = img.getpixel((x,y)) p = w * y + (x >> 3) + 8 # +8 for the palette - #if(!isset(this.d_out[p])) this.d_out[p] = 0 # Clear the bits first buf[p] |= (c & 0x1) << (7 - (x & 0x7)) - # write palette information - palette_size = 2 - bits_per_value = 1 + # write palette information, for indexed-1-bit we need palette with two values # write 8 palette bytes buf[0] = 0 buf[1] = 0 buf[2] = 0 buf[3] = 0 # Normally there is much math behind this, but for the current use case this is close enough + # only needs to be more complicated if we have more than 2 colors in the palette buf[4] = 255 buf[5] = 255 buf[6] = 255