Skip to content

ShowImage fails on non RGB888 images #9

@e-yes

Description

@e-yes

There are two files for testing: lena.png (exported with default GIMP settings) and lena2.png

Code to reproduce the issue:

from xgoscreen import LCD_2inch
lcd = LCD_2inch.LCD_2inch()
lcd.Init() #1 
from PIL import Image
im = Image.open("lena.png")
lcd.ShowImage(im)

the output:

File /usr/lib/python3.11/site-packages/xgoscreen/LCD_2inch.py:145, in LCD_2inch.ShowImage(self, Image, Xstart, Ystart)
    143 pix = self.np.zeros((self.width, self.height,2), dtype = self.np.uint8)
    144 #RGB888 >> RGB565
--> 145 pix[...,[0]] = self.np.add(self.np.bitwise_and(img[...,[0]],0xF8),self.np.right_shift(img[...,[1]],5))
    146 pix[...,[1]] = self.np.add(self.np.bitwise_and(self.np.left_shift(img[...,[1]],3),0xE0), self.np.right_shift(img[...,[2]],3))
    147 pix = pix.flatten().tolist()

ValueError: shape mismatch: value array of shape (240,1) could not be broadcast to indexing result of shape (240,320,1)

lena
lena2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions