慕工程0101907
我假设该数组的类型为 uint8 并代表红色、绿色和蓝色 您可以Pillow为此使用,例如from PyQt5 import QtWidgets, QtGuifrom PIL import Image, ImageQtimport numpy as np# generate datatable = np.zeros((256,256,3), dtype=np.uint8)for i in range(256): table[:,i,0] = i table[i,:,1] = itable[:,:,2] = (2*255 - table[:,:,0] - table[:,:,1]) // 2# convert data to QImage using PILimg = Image.fromarray(table, mode='RGB')qt_img = ImageQt.ImageQt(img)app = QtWidgets.QApplication([])w = QtWidgets.QLabel()w.setPixmap(QtGui.QPixmap.fromImage(qt_img))w.show()app.exec()