From ee6cbaebfaf1f6b574a20a63970a0c0a9e23bf6d Mon Sep 17 00:00:00 2001 From: dmv Date: Tue, 17 Nov 2009 13:17:02 +0000 Subject: [PATCH] Fix problem with dump view contents (with overlapping windows) for OCC viewer --- src/OCCViewer/OCCViewer_ViewWindow.cxx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 82c6c3011..ea102e914 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -75,6 +75,8 @@ static QEvent* l_mbPressEvent = 0; # include #endif +#include + const char* imageZoomCursor[] = { "32 32 3 1", ". c None", @@ -1427,8 +1429,25 @@ void OCCViewer_ViewWindow::onTrihedronShow() */ QImage OCCViewer_ViewWindow::dumpView() { - QPixmap px = QPixmap::grabWindow( myViewPort->winId() ); - return px.toImage(); + Handle(V3d_View) view = myViewPort->getView(); + if ( view.IsNull() ) + return QImage(); + QApplication::syncX(); + view->Update(); + view->Redraw(); + + unsigned char* data = new unsigned char[ (myViewPort->width()*myViewPort->height())*4 ]; + + QPoint p = myViewPort->mapFromParent(myViewPort->geometry().topLeft()); + + glReadPixels( p.x(), p.y(), myViewPort->width(), myViewPort->height(), GL_RGBA, GL_UNSIGNED_BYTE, + data); + + QImage anImage( data, myViewPort->width(), myViewPort->height(), QImage::Format_ARGB32 ); + anImage = anImage.mirrored(); + anImage = anImage.rgbSwapped(); + return anImage; + } bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img, -- 2.39.2