<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Shekhar wrote:
<blockquote cite="mid:47D141E2.1070405@sci.monash.edu.au" type="cite">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
Hi Manuel,<br>
<br>
Thats normal as far as my experience goes. You will need to get VTK to
pull the OpenGL stuff out of the window. Use the vtkWindowToImageFilter
class like:<br>
</blockquote>
No !!!<br>
If you completely do not take care of performance and complexity, then
let it be.<br>
But there is a more elegant, straightforward and clear solution - <br>
<br>
<tt> vtkRenderWindow* aWindow = anInteractor->getRenderWindow();<br>
unsigned char *aData = aWindow->GetRGBACharPixelData( 0, <br>
0, <br>
theHorizontalWindowDimension - 1, <br>
theVerticalWindowDimension - 1, <br>
0 );<br>
QImage anImage( aData, <br>
theHorizontalDimension, <br>
theVerticalDimension, <br>
QImage::Format_ARGB32 );<br>
<br>
// OpenGL gives ABGR (i.e. RGBA backwards); Qt wants ARGB<br>
anImage = anImage.rgbSwapped();<br>
<br>
anImage = anImage.mirrored();<br>
<br>
</tt>But surely, it will be much better if someone will show us a way,
when it could be done automatically through overriding of some QWidget
methods ...<br>
<blockquote cite="mid:47D141E2.1070405@sci.monash.edu.au" type="cite">vtkWindowToImageFilter
*windowToImage = vtkWindowToImageFilter::New();<br>
QVTKWidget *windowVTK = qobject_cast<QVTKWidget *>(activeWindow);<br>
<br>
///Capture Window<br>
windowToImage->SetInput(windowVTK->GetRenderWindow());<br>
windowToImage->Update();<br>
<br>
///Write/Save as PNG<br>
vtkPNGWriter *writer = vtkPNGWriter::New();<br>
writer->SetInputConnection(windowToImage->GetOutputPort());
//Cant group outside if's GCC compiler error<br>
writer->SetFileName(filename.toStdString().c_str());<br>
windowVTK->GetRenderWindow()->Render();<br>
writer->Write();<br>
writer->Delete();<br>
<br>
Hope that helps. <br>
Cheers Shakes.<br>
<br>
Manuel Feige wrote:
<blockquote cite="mid:003401c88036$883f53a0$14b2a8c0@tarox"
type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta content="MSHTML 6.00.6000.16608" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2"><font face="Times New Roman"
size="3">Hi
All!<br>
I'm trying to make a screenshot of the QVTKWidget with <br>
QPixmap::grabWidget(). But this results in a gray picture. I've got the
same <br>
problem in ParaView (3.0.2) when I save a screenshot as pdf file.<br>
I'm using VTK 5.0.3 with QT 4.3.3.<br>
Below you will find a simple test program.<br>
<br>
Regards,<br>
Manuel<br>
<br>
#include <QtGui><br>
#include <vtkRenderWindow.h><br>
#include <vtkRenderer.h><br>
#include <vtkPolyDataMapper.h><br>
#include <vtkSphereSource.h><br>
#include <QVTKWidget.h><br>
#include "MainWindow.h"<br>
MainWindow::MainWindow()<br>
{<br>
testAction = new QAction(tr("&Test"), this);<br>
connect(testAction, SIGNAL(triggered()), this, SLOT(test()));<br>
testMenu = menuBar()->addMenu(tr("&Test"));<br>
testMenu->addAction(testAction);<br>
createMainWidget();<br>
showMaximized();<br>
}<br>
void MainWindow::createMainWidget()<br>
{<br>
mainWidget = new QVTKWidget(this);<br>
vtkSphereSource* sphere = vtkSphereSource::New();<br>
vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();<br>
mapper->SetInput(sphere->GetOutput());<br>
vtkActor* actor = vtkActor::New();<br>
actor->SetMapper(mapper);<br>
vtkRenderer* ren = vtkRenderer::New();<br>
ren->AddActor(actor);<br>
mainWidget->GetRenderWindow()->AddRenderer(ren);<br>
setCentralWidget(mainWidget);<br>
}<br>
void MainWindow::test()<br>
{<br>
QPixmap pix = QPixmap::grabWidget(mainWidget);<br>
pix.save("C:/Test.bmp");<br>
} </font><br>
</font></div>
<pre wrap=""><hr size="4" width="90%">
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <a
moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
</pre>
</blockquote>
<br>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
</pre>
</blockquote>
<br>
</body>
</html>