PDA

View Full Version : Paint to pixmap directly



pospiech
9th June 2010, 13:22
Currently I create an QImage first and pass that to a pixmap. This is done with this code:


QImage QRgbMatrix::toImage()
{
QImage image = QImage(m_size_x, m_size_y, QImage::Format_RGB32);

int r, g, b; r = g = b = 0;
for ( int y = 0; y < m_size_y; y++ )
{
QRgb *line = (QRgb *)image.scanLine(y) ;
for ( int x = 0; x < m_size_x; x++ )
{
int pos = ArrPos(x,y);

r = d->red[pos];
g = d->green[pos];
b = d->blue[pos];

*line++ = qRgb(r, g, b);

}
}
return image;
}

QPixmap QRgbMatrix::toPixmap()
{
return QPixmap::fromImage(toImage());
}


Now my question is, if it would be possible to create a pixmap image without creating an QImage first.
My main concern about the QImage step is the time required for the conversions.

pospiech
10th June 2010, 09:34
I finished my application to work with the camera it shall images of. I experience a total time for the image creation (ToImage() function) of 200 ms (release) for a 5 MP image. Is there a general possibility to speed up this code?