Fix image saving from QT toolbar

This commit is contained in:
Leszek Swirski 2013-05-21 17:54:58 +01:00
parent 9a1cc06ebe
commit 7d0f6b4d68
2 changed files with 8 additions and 11 deletions

View File

@ -2473,35 +2473,33 @@ void DefaultViewPort::saveView()
if (!fileName.isEmpty()) //save the picture if (!fileName.isEmpty()) //save the picture
{ {
QString extension = fileName.right(3); QString extension = fileName.right(3);
// (no need anymore) create the image resized to receive the 'screenshot' // Create a new pixmap to render the viewport into
// image2Draw_qt_resized = QImage(viewport()->width(), viewport()->height(),QImage::Format_RGB888); QPixmap viewportPixmap(viewport()->size());
viewport()->render(&viewportPixmap);
QPainter saveimage(&image2Draw_qt_resized);
this->render(&saveimage);
// Save it.. // Save it..
if (QString::compare(extension, "png", Qt::CaseInsensitive) == 0) if (QString::compare(extension, "png", Qt::CaseInsensitive) == 0)
{ {
image2Draw_qt_resized.save(fileName, "PNG"); viewportPixmap.save(fileName, "PNG");
return; return;
} }
if (QString::compare(extension, "jpg", Qt::CaseInsensitive) == 0) if (QString::compare(extension, "jpg", Qt::CaseInsensitive) == 0)
{ {
image2Draw_qt_resized.save(fileName, "JPG"); viewportPixmap.save(fileName, "JPG");
return; return;
} }
if (QString::compare(extension, "bmp", Qt::CaseInsensitive) == 0) if (QString::compare(extension, "bmp", Qt::CaseInsensitive) == 0)
{ {
image2Draw_qt_resized.save(fileName, "BMP"); viewportPixmap.save(fileName, "BMP");
return; return;
} }
if (QString::compare(extension, "jpeg", Qt::CaseInsensitive) == 0) if (QString::compare(extension, "jpeg", Qt::CaseInsensitive) == 0)
{ {
image2Draw_qt_resized.save(fileName, "JPEG"); viewportPixmap.save(fileName, "JPEG");
return; return;
} }

View File

@ -522,7 +522,6 @@ private:
CvMat* image2Draw_mat; CvMat* image2Draw_mat;
QImage image2Draw_qt; QImage image2Draw_qt;
QImage image2Draw_qt_resized;
int nbChannelOriginImage; int nbChannelOriginImage;
//for mouse callback //for mouse callback