Create RGB 565 image from python array

I have a numpy array that is a group of RGB values. I would like to save them as an RGB 565 png image which I will then use as a THREE.js texture. How can I do this using Python?

Do I just need to write a corresponding 16-bit grayscale image? Ie, convert the R, G and B values ​​to 5, 6 and 5 bit numbers and then add them to binary? Is there a better way to do this? So far, I've used pypng to write 8 bit RGB pages.

+3


source to share





All Articles