简体   繁体   中英

RGB565 1D array to 3d RGB image

I have a 1D RGB565 array that I get from a camera and would like to convert it to a 3D RGB image.

So the image has QVGA resolution (320x240) and with the RGB565 format that results to a 153600 byte array.

在此处输入图像描述

Is there a quick way to convert that to an image, preferably with PIL?

thanks

this solves my problem

And here's the code:

length = 76800 # 320*240
one = [46888] * length # this would be the list of 76800 16bit RGB565 values
xdim = 320
ydim = 240
im = Image.new("RGB",(xdim,ydim))
for y in range(ydim):
   for x in range(xdim):
      px = one[x*y]
      im.putpixel((x,y),((px&0xF800) >> 8, (px&0x07E0) >> 3, (px&0x001F) << 3))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM