travick
3rd December 2011, 19:46
I have some data:
uchar* imageData;
then;
imageData = static_cast <uchar*>(realloc(imageData, imageSize));
renderer->render(imageData, imageWidth, imageHeight, imageSize);
and showing image up:
QImage image(imageData, imageWidth, imageHeight, imageBytesPerLine, QImage::Format_RGB888); //I need only RGB
QPixmap pixmap = QPixmap::fromImage(image);
ui->imagePlace->setPixmap(pixmap);
where
imagePlace is QLabel
Everything is all right until I want create image which takes lot of memory, for example size 8000px x 12000px
then allocated memory for imageData takes about 366MB (only 366MB).
Image still appears, but when doing
QPixmap pixmap = QPixmap::fromImage(image);
ui->imagePlace->setPixmap(pixmap);
Memory usage jump to above 700MB instead of 366MB
So my question is how to prevent this situation, because I want to show image which takes about 1GB or more, but in that situation memory usage is doubled (as far as I can see)!!
Is there way to direct display QImage on the screen?
What's more I wanna refresh this image several times (some kind of software generated animation)
I had search for reasonable solution but without success as far.
another strange thing:
when trying to display (in QLabel) image which has mode than 32767px width or height it fails, nothing is displayed.
It could be 32767px x 10px (takes only 959,97 KiB) and it shows correctly, but 32768px x 10px fails to show ...
uchar* imageData;
then;
imageData = static_cast <uchar*>(realloc(imageData, imageSize));
renderer->render(imageData, imageWidth, imageHeight, imageSize);
and showing image up:
QImage image(imageData, imageWidth, imageHeight, imageBytesPerLine, QImage::Format_RGB888); //I need only RGB
QPixmap pixmap = QPixmap::fromImage(image);
ui->imagePlace->setPixmap(pixmap);
where
imagePlace is QLabel
Everything is all right until I want create image which takes lot of memory, for example size 8000px x 12000px
then allocated memory for imageData takes about 366MB (only 366MB).
Image still appears, but when doing
QPixmap pixmap = QPixmap::fromImage(image);
ui->imagePlace->setPixmap(pixmap);
Memory usage jump to above 700MB instead of 366MB
So my question is how to prevent this situation, because I want to show image which takes about 1GB or more, but in that situation memory usage is doubled (as far as I can see)!!
Is there way to direct display QImage on the screen?
What's more I wanna refresh this image several times (some kind of software generated animation)
I had search for reasonable solution but without success as far.
another strange thing:
when trying to display (in QLabel) image which has mode than 32767px width or height it fails, nothing is displayed.
It could be 32767px x 10px (takes only 959,97 KiB) and it shows correctly, but 32768px x 10px fails to show ...