Add Image.toqimage().

This commit is contained in:
Andrey Golovizin 2014-08-21 23:20:30 +02:00
parent 48b179e2e0
commit 08e4382b66
2 changed files with 10 additions and 10 deletions

View file

@ -176,6 +176,15 @@ class Image(object):
array = np.fromstring(data, dtype=np.uint8).reshape(shape)
return cls(array)
def toqimage(self):
from PyQt4.QtGui import QImage
return QImage(
np.ascontiguousarray(self.data.astype(np.uint8)).data,
self.data.shape[1], self.data.shape[0],
self.data.shape[1] * 3,
QImage.Format_RGB888,
)
def unframe(self, width=2):
return Image(self.data[width:-width,width:-width])