[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] Re: QImage constructors
From: Phil Thompson <phil () riverbankcomputing ! co ! uk>
Date: 2009-07-12 17:38:29
Message-ID: 8c602056e1769a458fddcec42b0e92ad () localhost
[Download RAW message or body]
On Thu, 09 Jul 2009 14:47:25 +0200, Giovanni Bajo <rasky@develer.com>
wrote:
> Hi Phil,
>
> QImage has four different constructors that use existing pixel data:
>
> QImage(uchar *data, int width, int height, Format format);
> QImage(const uchar *data, int width, int height, Format format);
> QImage(uchar *data, int width, int height, int bytesPerLine, Format
> format);
> QImage(const uchar *data, int width, int height, int bytesPerLine,
> Format format);
>
> The "const uchar *" are semantically different from the "uchar *" ones;
> quoting the Assistant of the const version:
>
> =====================================================================
> Unlike the similar QImage constructor that takes a non-const data
> buffer, this version [the const one] will never alter the contents of
> the buffer. For example, calling QImage::bits() will return a deep copy
> of the image, rather than the buffer passed to the constructor. This
> allows for the efficiency of constructing a QImage from raw data,
> without the possibility of the raw data being changed.
> =====================================================================
>
> Unfortunately it looks like PyQt does not wrap the non-const version.
> This is specifically useful because I'm trying to construct QImage over
> a shared memory area and I would like to be able to modify it in-place.
>
> Since QSharedMemory.data() returns a sip.voidptr, I suggest declaring
> the missing constructors as taking a "void*" as first argument for now;
> this would be backward compatible and make my own use case work. For
> Python 3.0, you might want to explore the usage of bytes() vs
bytearray().
>
> Let me know if it makes sense. Thanks!
In tonight's snapshot - I'll leave the testing to you...
Phil
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic