[vtkusers] How to get the framebuffer

Ken Martin ken.martin at kitware.com
Wed Jul 25 10:46:58 EDT 2018


In current VTK I cannot see how GetPixelData can return null unless new
returns null due to being out of memory. The code boils down to

  unsigned char* ucdata = new unsigned char[width * height * 3];
  vtkRecti rect(x_low, y_low, width, height);
  this->ReadPixels(rect, front, GL_RGB, GL_UNSIGNED_BYTE, ucdata, right);
  return ucdata;

So if the return value is nullptr then "new" failed. So check around maybe
something else funny is going on.


On Wed, Jul 25, 2018 at 10:24 AM, Mathieu Westphal <
mathieu.westphal at kitware.com> wrote:

> Hi,
>
> It should work then.
>
> Take a look into :
> VTK/Rendering/OpenGL2/Testing/Cxx/TestRenderToImage.cxx
> VTK/Rendering/Core/vtkWindowToImageFilter.cxx
>
> Both are doing exactly what you are trying to do.
> The first one (the test) may be very useful to you.
>
> Best regards,
>
> Mathieu Westphal
>
> On Wed, Jul 25, 2018 at 4:20 PM, ling Hai <qyaoza at gmail.com> wrote:
>
>> Hi Mathieu,
>> Thank you for the response, I am already calling renderWindow->Render().
>> I tried reading the front, back, left and right buffers but am still unable
>> to get any data from the call. If it helps, I am not using shaders, color
>> points, or opacity the blending mode is composite, it is rendered by the
>> gpu.
>>
>> Linghai
>>
>> On Wed, Jul 25, 2018 at 3:52 AM, Mathieu Westphal <
>> mathieu.westphal at kitware.com> wrote:
>>
>>> Hi LingHai
>>>
>>> Make sure you have rendered into the renderWindow first.
>>> (renderWindow->Render())
>>> And try to read from the front and the back buffer.
>>>
>>> Best regards,
>>>
>>> Mathieu Westphal
>>>
>>> On Tue, Jul 24, 2018 at 7:57 PM, ling Hai <qyaoza at gmail.com> wrote:
>>>
>>>> Hi,
>>>> I am new to vtk and I am trying to get the front framebuffer from the
>>>> renderwindow like this:
>>>> int * dim = renderWindow->GetSize();
>>>> unsigned char* pixels = renderWindow->GetPixelData(0,0
>>>> ,dim[0]-1,dim[1]-1,true);
>>>>
>>>> but in pixels there is only a null value. I am using this on a 3d
>>>> render if that makes a difference the above segment of code called after
>>>> rendering the volume. What am I missing? Any help is appreciated thanks.
>>>> Linghai
>>>>
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>
>>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> https://public.kitware.com/mailman/listinfo/vtkusers
>>>>
>>>>
>>>
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
>
>


-- 
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
101 East Weaver Street
Carrboro, North Carolina
27510 USA

This communication, including all attachments, contains confidential and
legally privileged information, and it is intended only for the use of the
addressee.  Access to this email by anyone else is unauthorized. If you are
not the intended recipient, any disclosure, copying, distribution or any
action taken in reliance on it is prohibited and may be unlawful. If you
received this communication in error please notify us immediately and
destroy the original message.  Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180725/926f220c/attachment.html>


More information about the vtkusers mailing list