PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 90 - Allow buffer objects to be passed instead of strings
: Allow buffer objects to be passed instead of strings
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: BoostPythonGenerator
: HEAD
: All All
: P5 enhancement
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2009-11-03 12:22 EET by Stefan van der Walt
Modified: 2010-03-24 16:29 EET (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan van der Walt 2009-11-03 12:22:12 EET
It is often useful to pass a buffer instead of a string, for example:

a = np.asarray(np.ones((15, 15, 3))*255, dtype=np.uint8)

from PySide.QtCore import QByteArray
from PySide.QtGui import QImage

img = QImage(15, 15, QImage.Format_RGB888)
img.fromData(a.data)


This is explicitly supported by Sip:

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html#support-for-python-s-buffer-interfaceimport
numpy as np
Comment 1 Stefan van der Walt 2009-11-03 12:23:37 EET
Fixed code snippet:

import numpy as np
from PyQt4.QtGui import QImage

a = np.asarray(np.ones((15, 15, 3)) * 255, dtype=np.uint8)

img = QImage(15, 15, QImage.Format_RGB888)
img.fromData(a.data)
Comment 2 renato filho 2010-01-19 15:40:46 EET
fixed on commit: 20efa517c31a9339f7be5e7d6d8a13b6ee6214a4