Add Image.toqimage().
This commit is contained in:
parent
48b179e2e0
commit
08e4382b66
2 changed files with 10 additions and 10 deletions
|
|
@ -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])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue