[PyQt] Pixel Manipulation Very Slow?
zhangmdev at gmail.com
zhangmdev at gmail.com
Tue Aug 24 19:06:01 BST 2010
Hi,
I tried SIP to do the pixel manipulation in C/C++. Word is the class I
adopted from SIP hello world example. Must have a method return void*
void *Word::display()
{
for(int j=0; j< h; j++) {
for(int i=0; i< w; i++) {
_data[(j*w+i)*4] = 127;//Blue
_data[(j*w+i)*4+1] = 127;//Green
_data[(j*w+i)*4+2] = 255*_red;//Red
_data[(j*w+i)*4+3] = 0;//Alpha
}
}
return _data;
}
actually it returns char* _data, the pixels. I found the order of color is
a bit interesting, first the Blue, second is Green, third is Red, then
Alpha. The pointer will be sip.voidptr In python, I think.
image = QImage(self.a.display() , w, h, QtGui.QImage.Format_RGB32)
painter.drawImage(0, 0, image)
Now the speed is quite interactive.
zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100824/e8a9cacb/attachment.html>
More information about the PyQt
mailing list