rno
7th July 2016, 17:58
Hi,
I have a piece of code to display images one after the other. I noticed a memory leak when I "play" 100 images or so.
Here is the code
QImage image = QImage(width, height, QImage::Format_RGB32);
uint * scanLine;
for (int i = 0; i < height; i++)
{
scanLine = (uint *) image.scanLine(i);
for (int j = 0; j < width; j++)
{
pixel = 0xff - c[i * width + j];
scanLine[j] =qRgb(pixel, pixel, pixel); //memory leak here
}
}
delete [] c;
The image is displayed correctly but I cannot figure out what I am doing wrong here and why there is a memory leak.
height and width are 3000. c[] is a table of char with the image values. The image is a greyscale.
Can anyone help me solving this memory leak?
Cheers,
Arnaud
I have a piece of code to display images one after the other. I noticed a memory leak when I "play" 100 images or so.
Here is the code
QImage image = QImage(width, height, QImage::Format_RGB32);
uint * scanLine;
for (int i = 0; i < height; i++)
{
scanLine = (uint *) image.scanLine(i);
for (int j = 0; j < width; j++)
{
pixel = 0xff - c[i * width + j];
scanLine[j] =qRgb(pixel, pixel, pixel); //memory leak here
}
}
delete [] c;
The image is displayed correctly but I cannot figure out what I am doing wrong here and why there is a memory leak.
height and width are 3000. c[] is a table of char with the image values. The image is a greyscale.
Can anyone help me solving this memory leak?
Cheers,
Arnaud