[vtk-developers] Drawing on a vtkRenderWindow in C#/ActiViz

David Cole david.cole at kitware.com
Mon Nov 7 14:43:43 EST 2011


Add:

      fi.Update();

before the call to GetOutput. Without it, the output is not properly
populated, and the width and height come back as "-1" which we use as
array indices internal to the "ToBitmap" method, ... which is where
the invalid argument exception comes from.

If you call Update before GetOutput, all should be well, and you
should get a bitmap back.

(Sorry for the delayed response, by the way... Hopefully, later is
better than never...)


Cheers,
David C.


On Sun, Sep 18, 2011 at 3:34 PM, cakbulut <cakbulut at web.de> wrote:
> Hi David,
>
> I have tried the vtkWindowToImageFilter class, but it does not work. I do
> not know where I am making a mistake. Here is my code:
>
>            vtkDICOMImageReader reader = new vtkDICOMImageReader();
>
>            reader.SetDirectoryName("C:\\vtkDev\\Book\\data\\SE000002");
>            reader.Update();
>
>            mapper.SetInput(reader.GetOutput());
>
>            actor = new vtkActor2D();
>            actor.SetMapper(mapper);
>
>            vtkRenderer ren1 =
> renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer();
>            vtkRenderWindow renWin = renderWindowControl1.RenderWindow;
>
>            // Add the actors to the renderer, set the window size
>            //
>            ren1.AddViewProp(actor);
>            renWin.SetSize(250, 250);
>
>            vtkWindowToImageFilter fi = new vtkWindowToImageFilter();
>            fi.SetInput(renderWindowControl1.RenderWindow);
>            vtkImageData v = fi.GetOutput();
>
>            try
>            {
>
>                Bitmap bitmap = v.ToBitmap(); *//Here I get Invalid Argument
> Exception*
>                pictureBox1.Image = bitmap;
>            }
>            catch (Exception d)
>            {
>                MessageBox.Show(d.Message);
>            }
>
> Have you got an idea?
>
> Best regards
> cakbulut
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Drawing-on-a-vtkRenderWindow-in-C-ActiViz-tp4802425p4816781.html
> Sent from the VTK - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>



More information about the vtk-developers mailing list