找不到文档,只在网上找到一些语焉不详,执行错误的代码,鼓捣了一个晚上,研(luan)究(gao)成功
def img2pixmap(self, image): Y, X = image.shape[:2] self._bgra = np.zeros((Y, X, 4), dtype=np.uint8, order='C') self._bgra[..., 0] = image[..., 2] self._bgra[..., 1] = image[..., 1] self._bgra[..., 2] = image[..., 0] qimage = QtGui.QImage(self._bgra.data, X, Y, QtGui.QImage.Format_RGB32) pixmap = QtGui.QPixmap.fromImage(qimage) return pixmap
调用:
self.lable_img.setPixmap(self.img2pixmap(self.plus))
乱搞了一个晚上……