[PyKDE] Re: question re QImage.setPixel in PyQt3

Tony Willis Tony.Willis at nrc-cnrc.gc.ca
Fri Mar 10 19:20:40 GMT 2006


Hi Phil

Thanks for pointing this out. I see the issue here.

Cheers

Tony
-------------
>
> On Friday 10 March 2006 5:36 pm, Tony Willis wrote:
>> Hi
>>
>> I'm using PyQt3.13 and have run across a problem with the
>> python interface to the QImage setPixel method.  You can see this
>> directly by replacing line 90 of examples3/desktop.py
>> image.setPixel(x,y,(x+y)%128)
>> by
>> image.setPixel(x,y, qRgb(x,y,0))
>>
>> this will result in error messsages such as
>> Image::setPixel: index=-16050688 out of range
>>
>> A call to Qimage.setColor with a qRgb object does work.
>>
>> The problem is that the setPixel method is expecting an
>> unsigned int - the call in the original demo will work
>> because (x+y)%128 will not get near the sign bit for a
>> python int, whereas  qRgb(x,y,0) can return an unsigned
>> value > the range of a python int.
>>
>> I see that qimage.sip has void setPixel(int,int,uint);
>> whereas it has void setColor(int,QRgb);
>>
>> Thanks for any advice on how to get around this problem.
>
> This isn't a PyQt problem. From the Qt docs...
>
> "If the image is a paletted image (depth() <= 8) and index_or_rgb >=
> numColors(), the result is undefined."
>
> Phil

___________
Tony Willis
National Research Council   Tony.Willis at nrc-cnrc.gc.ca
Box 248                     (250)493-2277
Penticton, BC  V2A 6J9      fax: 493-7767
Government of Canada        Gouvernement du Canada




More information about the PyQt mailing list