<div dir="ltr"><div><div>I have used this code and worked form me (VTK 6.1, in Visual Studio 2010 MFC single dialog project)</div></div><div><br></div><div>Resetting camera may bring hidden sane to visible range...</div><div><br></div><div> vtkSmartPointer<vtkRenderWindow> renderWindow;</div><div>vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor;<br></div><div><br></div><div> .......</div><div><br></div><div> vtkTest->firstRenderer->ResetCameraClippingRange();<br> vtkTest->secondRenderer->ResetCamera();<br> vtkTest->renderWindowInteractor->Render();</div><div><br></div><div> ......</div><div><br></div><div> vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter; <br> windowToImageFilter=vtkSmartPointer<vtkWindowToImageFilter>::New();<br> windowToImageFilter->SetInput(renderWindow);<br> windowToImageFilter->ReadFrontBufferOff();<br> windowToImageFilter->SetViewport(0.0, 0.0, 0.5, 1.0);</div><div>//Because I have used 2 renderers per rendering window<br> windowToImageFilter->Update();<br> vtkImageData* image=windowToImageFilter->GetOutput();</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 10, 2015 at 7:27 AM, Fredrik <span dir="ltr"><<a href="mailto:frejon@gmail.com" target="_blank">frejon@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for the reply Miroslav. I get an immediate Fatal Crash when I add a renderWindow.render() line.<br><br><div><br></div><div><div># A fatal error has been detected by the Java Runtime Environment:</div><div>#</div><div># SIGSEGV (0xb) at pc=0x000000012f4b8979, pid=42597, tid=54087</div><div>#</div><div># JRE version: Java(TM) SE Runtime Environment (8.0_45-b14) (build 1.8.0_45-b14)</div><div># Java VM: Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode bsd-amd64 compressed oops)</div><div># Problematic frame:</div><div># C [libvtkRenderingOpenGL.jnilib+0x179979] vtkUpload3D<unsigned char>::Upload(void*, unsigned char*, unsigned int*, int, long long*, int, int*)+0x149</div><br>full crash report here: <a href="http://pastebin.com/bvfxB3er" target="_blank">http://pastebin.com/bvfxB3er</a><br><br>Which is interesting, I can ask the JOGLVisPanel itself to render flawlessly, but not the vtkRenderWindow contained therein.<br>I can't really make sense of the error report. If anyone could take pity on my plight and help me I'd be most appreciative. I'm suspecting some kind of JOGL/VTK/Mac problem. If it's any help, I'm debugging code that used to work years ago under JDK 6 and older versions of VTK.<span class="HOEnZb"><font color="#888888"><br><br>// Fredrik</font></span><div><div class="h5"><br><div class="gmail_extra"><br><div class="gmail_quote">2015-06-09 19:43 GMT+02:00 Miroslav Drahos <span dir="ltr"><<a href="mailto:mdrahos@thinksurgical.com" target="_blank">mdrahos@thinksurgical.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">Frederik,<br>
you should call vtkRenderWindow::Render() before updating the pipeline.<br>
This is what has worked for me reliably:<br>
<br>
VTK_CREATE(vtkWindowToImageFilter, w2i);<br>
w2i->SetInput(rw);<br>
w2i->ReadFrontBufferOff();<br>
rw->Render();<br>
w2i->Modified(); // See doc <a href="http://www.vtk.org/doc/nightly/html/classvtkWindowToImageFilter.html#details" target="_blank">http://www.vtk.org/doc/nightly/html/classvtkWindowToImageFilter.html#details</a><br>
<br>
VTK_CREATE(vtkPNGWriter, writer);<br>
writer->SetFileName(fname.c_str());<br>
writer->SetInputConnection(w2i->GetOutputPort());<br>
writer->Write();<br>
<br>
where VTK_CREATE is a widely used macro:<br>
<br>
#define VTK_CREATE(type, name) vtkSmartPointer<type> name = vtkSmartPointer<type>::New();<br>
<br>
HTH,<br>
Miro<br>
<br>
________________________________________<br>
From: vtkusers [<a href="mailto:vtkusers-bounces@vtk.org" target="_blank">vtkusers-bounces@vtk.org</a>] On Behalf Of Fredrik [<a href="mailto:frejon@gmail.com" target="_blank">frejon@gmail.com</a>]<br>
Sent: Tuesday, June 09, 2015 8:55 AM<br>
To: Scott Wittenburg<br>
Cc: <a href="mailto:vtkusers@public.kitware.com" target="_blank">vtkusers@public.kitware.com</a><br>
Subject: Re: [vtkusers] vtkWindowToImageFilter - black image<br>
<span><br>
Hi Scott, thanks for the reply. Unfortunately it didn't help. I think I remember some other thread with the "ShouldRerender" flag, but I think that mentioned it should be windowToImageFilter.ShouldRerenderOff();<br>
, not on. I tried both anyway, but no change<br>
<br>
All the best,<br>
Fredrik<br>
<br>
</span>2015-06-09 17:33 GMT+02:00 Scott Wittenburg <<a href="mailto:scott.wittenburg@kitware.com" target="_blank">scott.wittenburg@kitware.com</a><mailto:<a href="mailto:scott.wittenburg@kitware.com" target="_blank">scott.wittenburg@kitware.com</a>>>:<br>
<span>Hi Frederik,<br>
<br>
I believe I have encountered this before. What solved it for me was turning on the "ShouldRerender" flag in addition to what you have set. Something like:<br>
<br>
windowToImageFilter.ShouldRerenderOn();<br>
<br>
could possibly help.<br>
<br>
Cheers,<br>
Scott<br>
<br>
<br>
<br>
</span><span>On Tue, Jun 9, 2015 at 9:02 AM, Fredrik <<a href="mailto:frejon@gmail.com" target="_blank">frejon@gmail.com</a><mailto:<a href="mailto:frejon@gmail.com" target="_blank">frejon@gmail.com</a>>> wrote:<br>
Hello. There are several threads on this topic, and the few I see, the proposed solutions are not enough or the thread is left unresolved. see this:<br>
<br>
<a href="http://public.kitware.com/pipermail/vtkusers/2014-October/085358.html" target="_blank">http://public.kitware.com/pipermail/vtkusers/2014-October/085358.html</a><br>
<a href="http://public.kitware.com/pipermail/vtkusers/2014-October/085294.html" target="_blank">http://public.kitware.com/pipermail/vtkusers/2014-October/085294.html</a><br>
<br>
I still am unable to generate anything else than a black image.<br>
I'm on the latest VTK, under Mac OS X 10.10. I also tried offscreen rendering, but no luck.<br>
<br>
Hours of googling and testing solutions have proven unsuccessful, I'd really appreciate if anyone could help me.<br>
<br>
here's a snippet of my code if you think it'll help<br>
<br>
tempFile = "xyz.bmp";<br>
// write to temporary bmp file<br>
vtkBMPWriter writer = new vtkBMPWriter();<br>
vtkWindowToImageFilter windowToImageFilter = new vtkWindowToImageFilter();<br>
windowToImageFilter.ReadFrontBufferOff();<br>
windowToImageFilter.SetMagnification(1);<br>
windowToImageFilter.SetInput(renderWindow);<br>
windowToImageFilter.SetInputBufferTypeToRGBA();<br>
windowToImageFilter.ReadFrontBufferOff();<br>
<br>
windowToImageFilter.Update();<br>
<br>
windowToImageFilter.ReadFrontBufferOff();<br>
writer.SetInputConnection(windowToImageFilter.GetOutputPort());<br>
writer.SetFileName(tempFile);<br>
writer.Write();<br>
<br>
<br>
<br>
Kind Regards, Fredrik<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
</span>Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>><br>
<div><div><br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br>
<br>
<br>
</div></div></blockquote></div><br></div></div></div></div></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">kinde mekuria</div>
</div>