Currently I create an QImage first and pass that to a pixmap. This is done with this code:
{
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;
}
{
return QPixmap::fromImage(toImage
());
}
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());
}
To copy to clipboard, switch view to plain text mode
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.
Bookmarks