void MagicCube::PaintFrame(AVFrame *pFrame, int width, int height)
{
int x, y;
int *src = (int*)pFrame->data[0];
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
image.setPixel(x, y, src[x] & 0x00ffffff);
}
src += width;
}
painter.
drawImage(QRect(10,
37, width, height
), image
);
}
void MagicCube::PaintFrame(AVFrame *pFrame, int width, int height)
{
QImage image(width, height, QImage::Format_RGB32);
int x, y;
int *src = (int*)pFrame->data[0];
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
image.setPixel(x, y, src[x] & 0x00ffffff);
}
src += width;
}
QPainter painter(this);
painter.drawImage(QRect(10, 37, width, height), image);
}
To copy to clipboard, switch view to plain text mode
The current code is working, but it has its problems - it's using 40+% of CPU. So, is there a way to avoid all the loops and just load the data into image (I tried a lot of combinations but with no success) or any other method?
Bookmarks