}
//***********************************************
-QImage XGUI_ViewPort::dumpView(QRect theRect, bool toUpdate)
+QImage XGUI_ViewPort::dumpView(unsigned char*& theData, QRect theRect, bool toUpdate)
{
Handle(V3d_View) view = getView();
if (view.IsNull())
}
QApplication::syncX();
- unsigned char* data = new unsigned char[aWidth * aHeight * 4];
+ theData = new unsigned char[aWidth * aHeight * 4];
QPoint p;
if (theRect.isNull()) {
view->Redraw(theRect.x(), theRect.y(), theRect.width(), theRect.height());
p = theRect.topLeft();
}
- glReadPixels(p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ glReadPixels(p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, theData);
- QImage anImage(data, aWidth, aHeight, QImage::Format_ARGB32);
+ QImage anImage(theData, aWidth, aHeight, QImage::Format_ARGB32);
anImage = anImage.mirrored();
anImage = anImage.rgbSwapped();
return anImage;
QRect aImgRect(
QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), aRect.width(), aRect.height()));
- QImage aImg = myVPort->dumpView(aImgRect, myResize);
+ unsigned char* aData = 0;
+ QImage aImg = myVPort->dumpView(aData, aImgRect, myResize);
if (!aImg.isNull())
aPainter.drawImage(aRect, aImg);
myResize = false;
aOpt.rect = style->subElementRect(QStyle::SE_ToolBarHandle, &aOpt, this);
if (aOpt.rect.isValid())
style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &aOpt, &aPainter, this);
+ if (aData)
+ delete aData;
}
//**************************************************************************
QRect aImgRect(
QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), aRect.width(), aRect.height()));
- QImage aImg = myVPort->dumpView(aImgRect, myResize);
+ unsigned char* aData = 0;
+ QImage aImg = myVPort->dumpView(aData, aImgRect, myResize);
if (!aImg.isNull())
QPainter(this).drawImage(aRect, aImg);
myResize = false;
QLabel::paintEvent(theEvent);
+ if (aData)
+ delete aData;
}
//**************************************************************************
//****************************************************************
void XGUI_ViewWindow::onMinimize()
{
- QPixmap aPMap = QPixmap::fromImage(myViewPort->dumpView());
+ unsigned char* aData = 0;
+ QPixmap aPMap = QPixmap::fromImage(myViewPort->dumpView(aData));
int aW = width();
int aH = height();
double aR = aW / 100.;
parentWidget()->lower();
windowDeactivated();
myViewer->onWindowMinimized((QMdiSubWindow*) parentWidget());
+ delete aData;
}
//****************************************************************
&aSelectedFilter);
if (!aFileName.isNull()) {
QApplication::setOverrideCursor(Qt::WaitCursor);
- QImage aPicture = myViewPort->dumpView();
+ unsigned char* aData = 0;
+ QImage aPicture = myViewPort->dumpView(aData);
QString aFmt = XGUI_Tools::extension(aFileName).toUpper();
if (aFmt.isEmpty())
#endif
else
aPicture.save(aFileName, aFmt.toLatin1());
+ delete aData;
QApplication::restoreOverrideCursor();
}
}