Hey,

The documentation lists a constructor for setting the colortable for a
indexed QImage but doesn't specify what is supposed to be passed in...

http://www.pyside.org/docs/pyside/PySide/QtGui/QImage.html#PySide.QtGui.PySi
de.QtGui.QImage.setColorTable

The corresponding Qt function takes a QVector<QRgb>, but there does not
appear to be a QVector structure in PySide...

http://doc.qt.nokia.com/latest/qimage.html#setColorTable

Can somebody tell me what the correct way to create a color table for an
indexed QImage using PySide is? Also, somebody should probably update the
documentation so that the proper arg types are listed.

- Sam

On 7/29/11 4:00 AM, "[email protected]"
<[email protected]> wrote:

> Send PySide mailing list submissions to
> [email protected]
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.pyside.org/listinfo/pyside
> or, via email, send a message with subject or body 'help' to
> [email protected]
> 
> You can reach the person managing the list at
> [email protected]
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of PySide digest..."
> 
> 
> Today's Topics:
> 
>    1. Re: QImage around existing image data buffer; C++ vs  pyside
>       (Gordon L. Kindlmann)
>    2. Re: QImage around existing image data buffer; C++ vs  pyside
>       (Gerald Storer)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Fri, 29 Jul 2011 00:37:17 -0500
> From: "Gordon L. Kindlmann" <[email protected]>
> To: [email protected]
> Subject: Re: [PySide] QImage around existing image data buffer; C++ vs
> pyside
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
> 
> On Wednesday 27 Jul 2011 10:09:58 Hugo Parente Lima wrote:
>> 
> 
>> On Wednesday 27 July 2011 02:15:35 Gordon L. Kindlmann wrote:
>>> Hello,
>>> 
>>> I see from
>>> 
>>> http://doc.qt.nokia.com/latest/qimage.html#QImage-4
>>> 
>>> that I can create a QImage around an existing ray image data buffer
>>> in
>>> memory, communicated by the "uchar * data" argument, which is what I
>>> want.
>>> 
>>> However, looking at
>>> 
>>> http://www.pyside.org/docs/pyside/PySide/QtGui/QImage.html#PySide.QtGui.QIm
>>> age
>>> 
>>> (which seems to be based on the same documentation) the corresponding
>>> PySide constructor seems to take a "data" argument of type "uchar".
>>> Is this right?
>> 
>> The docs, no, but you can pass a Python buffer object to the QImage
>> constructor.
>> 
>>> Can someone let me know if it possible or not to use PySide to
>>> display
>>> in-memory image data, referenced by a pointer?  The image data is
>>> generated by an extension module written in C.
>> 
>> If the value returned by this extension implements the Python buffer
>> interface
>> it's possible.
>> 
>>> Thanks,
>>> Gordon
>>> 
> 
> Thanks for the info.  Just to be certain, you are referring this?
> 
> http://docs.python.org/c-api/buffer.html
> 
> Do you know of any code examples that demonstrate this being used with
> PySide?  Googling for 'pyside "buffer interface"' was not so
> informative.  I'm especially interested in examples that don't depend
> on numpy, for simplicity's sake.
> 
> Thanks,
> Gordon
> 
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Fri, 29 Jul 2011 13:50:29 +0800
> From: Gerald Storer <[email protected]>
> To: [email protected]
> Cc: [email protected]
> Subject: Re: [PySide] QImage around existing image data buffer; C++ vs
> pyside
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
> 
> On 29/07/2011 1:37 PM, Gordon L. Kindlmann wrote:
>> On Wednesday 27 Jul 2011 10:09:58 Hugo Parente Lima wrote:
>>> 
>> 
>>> On Wednesday 27 July 2011 02:15:35 Gordon L. Kindlmann wrote:
>>>> Hello,
>>>> 
>>>> I see from
>>>> 
>>>> http://doc.qt.nokia.com/latest/qimage.html#QImage-4
>>>> 
>>>> that I can create a QImage around an existing ray image data buffer in
>>>> memory, communicated by the "uchar * data" argument, which is what I
>>>> want.
>>>> 
>>>> However, looking at
>>>> 
>>>> http://www.pyside.org/docs/pyside/PySide/QtGui/QImage.html#PySide.QtGui.QIm
>>>> 
>>>> age
>>>> 
>>>> (which seems to be based on the same documentation) the corresponding
>>>> PySide constructor seems to take a "data" argument of type "uchar".
>>>> Is this right?
>>> 
>>> The docs, no, but you can pass a Python buffer object to the QImage
>>> constructor.
>>> 
>>>> Can someone let me know if it possible or not to use PySide to display
>>>> in-memory image data, referenced by a pointer?  The image data is
>>>> generated by an extension module written in C.
>>> 
>>> If the value returned by this extension implements the Python buffer
>>> interface
>>> it's possible.
>>> 
>>>> Thanks,
>>>> Gordon
>>>> 
>> 
>> Thanks for the info.  Just to be certain, you are referring this?
>> 
>> http://docs.python.org/c-api/buffer.html
>> 
>> Do you know of any code examples that demonstrate this being used with
>> PySide?  Googling for 'pyside "buffer interface"' was not so
>> informative.  I'm especially interested in examples that don't depend
>> on numpy, for simplicity's sake.
>> 
>> Thanks,
>> Gordon
> Hi,
> You shouldn't be searching for something like that.  Once you have your
> data in a form that implements the /Python/ buffer interface, getting a
> QImage is trivial.
> Something like this will do:
> qImage = QtGui.QImage(myBuffer,
>                        width,
>                        height,
>                        QtGui.QImage.Format_ARGB32) # Obviously adapt the
> image format to the appropriate value.
> 
> What you should be really doing is figuring out how to get your data
> wrapped as a Python buffer which is completely independent of PySide.
> Note that Python strings also implement the buffer interface if it is
> easier to wrap your data as a string.
> 
> Gerald.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: 
> <http://lists.pyside.org/pipermail/pyside/attachments/20110729/b7b48abb/attach
> ment-0001.html>
> 
> ------------------------------
> 
> _______________________________________________
> PySide mailing list
> [email protected]
> http://lists.pyside.org/listinfo/pyside
> 
> 
> End of PySide Digest, Vol 24, Issue 29
> **************************************


_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside

Reply via email to