Commit ac72811d authored by Dirk Wilden's avatar Dirk Wilden

fixed some minor issues with Snapshot functions

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6353 383ad7c9-94d9-4d36-a494-682f7c89f535
parent fcaacee2
......@@ -339,7 +339,7 @@ void actionMode ( Viewer::ActionMode _mode) {
}
void getCurrentViewImage(QImage& _image) {
viewer( activeExaminer() )->copyToImage( _image );
viewer( activeExaminer() )->snapshot( _image, true );
}
Viewer::ViewerProperties& viewerProperties(int _id) {
......
......@@ -1094,29 +1094,9 @@ void Core::resizeViewers(int _width, int _height ){
lastWidth_ = coreWidget_->glView_->width();
lastHeight_ = coreWidget_->glView_->height();
//now take the snapshot
switch ( coreWidget_->baseLayout_->mode() ){
case QtMultiViewLayout::SingleView:
{
//+4,+20 to to get the correct dimension when using snapshotFunction
coreWidget_->glView_->resize(_width+4, _height+20);
break;
}
case QtMultiViewLayout::Grid:
{
//+6,+22 to to get the correct dimension when using snapshotFunction
coreWidget_->glView_->resize(_width+6, _height+22);
break;
}
case QtMultiViewLayout::HSplit:
{
//+6,+20 to to get the correct dimension when using snapshotFunction
coreWidget_->glView_->resize(_width+6, _height+20);
break;
}
default: break;
}
//+4,+20 to to get the correct dimension when using snapshotFunction
coreWidget_->glView_->resize(_width+4, _height+20);
}
}
......
......@@ -388,16 +388,19 @@ void CoreWidget::viewerSnapshotDialog() {
examiner_widgets_[2]->snapshot(img2);
examiner_widgets_[3]->snapshot(img3);
QImage finalImage(img0.width() + img1.width(), img0.height() + img2.height(), QImage::Format_ARGB32_Premultiplied);
QImage finalImage(img0.width() + img1.width()+2, img0.height() + img2.height()+2, QImage::Format_ARGB32_Premultiplied);
QPainter painter(&finalImage);
painter.fillRect(0,0,finalImage.width(), finalImage.height(), QBrush(Qt::gray));
painter.drawImage(QRectF( 0, 0, img0.width(), img0.height()),img0,
QRectF( 0, 0, img0.width(), img0.height()) );
painter.drawImage(QRectF(img0.width(), 0, img1.width(), img1.height()),img1,
painter.drawImage(QRectF(img0.width()+2, 0, img1.width(), img1.height()),img1,
QRectF( 0, 0, img1.width(), img1.height()) );
painter.drawImage(QRectF( 0, img0.height(), img2.width(), img2.height()),img2,
painter.drawImage(QRectF( 0,img0.height()+2, img2.width(), img2.height()),img2,
QRectF( 0, 0, img2.width(), img2.height()) );
painter.drawImage(QRectF(img0.width(), img0.height(), img3.width(), img3.height()),img3,
painter.drawImage(QRectF(img0.width()+2, img0.height()+2, img3.width(), img3.height()),img3,
QRectF( 0, 0, img3.width(), img3.height()) );
finalImage.save(newName);
......@@ -413,16 +416,19 @@ void CoreWidget::viewerSnapshotDialog() {
examiner_widgets_[2]->snapshot(img2);
examiner_widgets_[3]->snapshot(img3);
QImage finalImage(img0.width() + img1.width(), img0.height(), QImage::Format_ARGB32_Premultiplied);
QImage finalImage(img0.width() + img1.width() +2, img0.height(), QImage::Format_ARGB32_Premultiplied);
QPainter painter(&finalImage);
painter.fillRect(0,0,finalImage.width(), finalImage.height(), QBrush(Qt::gray));
painter.drawImage(QRectF( 0, 0, img0.width(), img0.height()),img0,
QRectF( 0, 0, img0.width(), img0.height()) );
painter.drawImage(QRectF(img0.width(), 0, img1.width(), img1.height()),img1,
painter.drawImage(QRectF(img0.width()+2, 0, img1.width(), img1.height()),img1,
QRectF( 0, 0, img1.width(), img1.height()) );
painter.drawImage(QRectF(img0.width(), img1.height(), img2.width(), img2.height()),img2,
painter.drawImage(QRectF(img0.width()+2, img1.height()+2, img2.width(), img2.height()),img2,
QRectF( 0, 0, img2.width(), img2.height()) );
painter.drawImage(QRectF(img0.width(), img1.height()+img2.height(), img3.width(),img3.height()),img3,
painter.drawImage(QRectF(img0.width()+2, img1.height()+img2.height()+4, img3.width(),img3.height()),img3,
QRectF( 0, 0, img3.width(), img3.height()) );
finalImage.save(newName);
......@@ -480,16 +486,19 @@ void CoreWidget::viewerSnapshot() {
examiner_widgets_[2]->snapshot(img2);
examiner_widgets_[3]->snapshot(img3);
QImage finalImage(img0.width() + img1.width(), img0.height() + img2.height(), QImage::Format_ARGB32_Premultiplied);
QImage finalImage(img0.width() + img1.width() + 2, img0.height() + img2.height() + 2, QImage::Format_ARGB32_Premultiplied);
QPainter painter(&finalImage);
painter.fillRect(0,0,finalImage.width(), finalImage.height(), QBrush(Qt::gray));
painter.drawImage(QRectF( 0, 0, img0.width(), img0.height()),img0,
QRectF( 0, 0, img0.width(), img0.height()) );
painter.drawImage(QRectF(img0.width(), 0, img1.width(), img1.height()),img1,
painter.drawImage(QRectF(img0.width()+2, 0, img1.width(), img1.height()),img1,
QRectF( 0, 0, img1.width(), img1.height()) );
painter.drawImage(QRectF( 0, img0.height(), img2.width(), img2.height()),img2,
painter.drawImage(QRectF( 0, img0.height()+2, img2.width(), img2.height()),img2,
QRectF( 0, 0, img2.width(), img2.height()) );
painter.drawImage(QRectF(img0.width(), img0.height(), img3.width(), img3.height()),img3,
painter.drawImage(QRectF(img0.width()+2, img0.height()+2, img3.width(), img3.height()),img3,
QRectF( 0, 0, img3.width(), img3.height()) );
finalImage.save(suggest);
......@@ -505,16 +514,19 @@ void CoreWidget::viewerSnapshot() {
examiner_widgets_[2]->snapshot(img2);
examiner_widgets_[3]->snapshot(img3);
QImage finalImage(img0.width() + img1.width(), img0.height(), QImage::Format_ARGB32_Premultiplied);
QImage finalImage(img0.width() + img1.width() + 2, img0.height(), QImage::Format_ARGB32_Premultiplied);
QPainter painter(&finalImage);
painter.fillRect(0,0,finalImage.width(), finalImage.height(), QBrush(Qt::gray));
painter.drawImage(QRectF( 0, 0, img0.width(), img0.height()),img0,
QRectF( 0, 0, img0.width(), img0.height()) );
painter.drawImage(QRectF(img0.width(), 0, img1.width(), img1.height()),img1,
painter.drawImage(QRectF(img0.width()+2, 0, img1.width(), img1.height()),img1,
QRectF( 0, 0, img1.width(), img1.height()) );
painter.drawImage(QRectF(img0.width(), img1.height(), img2.width(), img2.height()),img2,
painter.drawImage(QRectF(img0.width()+2, img1.height()+2, img2.width(), img2.height()),img2,
QRectF( 0, 0, img2.width(), img2.height()) );
painter.drawImage(QRectF(img0.width(), img1.height()+img2.height(), img3.width(),img3.height()),img3,
painter.drawImage(QRectF(img0.width()+2, img1.height()+img2.height()+4, img3.width(),img3.height()),img3,
QRectF( 0, 0, img3.width(), img3.height()) );
finalImage.save(suggest);
......
......@@ -104,6 +104,8 @@
#include <OpenFlipper/common/GlobalOptions.hh>
#include <QGLFramebufferObject>
//== NAMESPACES ===============================================================
......@@ -430,7 +432,10 @@ glViewer::copyToImage( QImage& _image,
unsigned int _w, unsigned int _h,
GLenum /* _buffer */ )
{
makeCurrent();
// qApp->processEvents();
// makeCurrent();
_image = glWidget_->grabFrameBuffer(true).copy (_l, _t, _w, _h).convertToFormat (QImage::Format_RGB32);
}
......@@ -1867,17 +1872,36 @@ void glViewer::slotPropertiesUpdated() {
updateGL();
}
void glViewer::snapshot(QImage& _image)
void glViewer::snapshot(QImage& _image, bool _offScreenRendering)
{
makeCurrent();
qApp->processEvents();
makeCurrent();
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
paintGL();
glFinish();
if ( _offScreenRendering ){
QGLFramebufferObject fb( glstate_->context_width(), glstate_->context_height(), QGLFramebufferObject::CombinedDepthStencil);
if ( fb.isValid() ){
fb.bind();
qApp->processEvents();
makeCurrent();
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
paintGL();
glFinish();
_image = fb.toImage().copy(scenePos().x(), scenePos().y(), glWidth(), glHeight());
return;
}
}
makeCurrent();
qApp->processEvents();
makeCurrent();
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
paintGL();
glFinish();
copyToImage(_image, scenePos().x(), scenePos().y(), glWidth(), glHeight(), GL_BACK);
copyToImage(_image, scenePos().x(), scenePos().y(), glWidth(), glHeight(), GL_BACK);
}
void glViewer::snapshot()
......
......@@ -695,7 +695,7 @@ private:
virtual void snapshot();
/// Take a snapshot and store it in the given image
virtual void snapshot(QImage& _image);
virtual void snapshot(QImage& _image, bool _offScreenRendering = false);
/** @} */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment