python实现rgb565转图片

#coding=utf-8
import numpy as np
import cv2

import Image
import matplotlib.pyplot as pyplot

from girl import girl
from bmw import bmw
from bt import bt


img=bt
h = 100
w = 100


rgbArray = np.zeros((h,w,3),np.uint8)


flat = np.array(img)
grayImage = flat.reshape(h, w)

 

rgbArray[...,0] = grayImage[...]>>11
rgbArray[...,1] = (grayImage[...]&2016)>>5
rgbArray[...,2] = grayImage[...]&31


#print rgbArray[...,0]


image = Image.fromarray(rgbArray,'RGB')


image.save('./tmp.png')


pyplot.imshow(image)
pyplot.show()




 

 

你可能感兴趣的:(python小程序)