ZBuffer Bitmap Capture in C#

Hey there,
I need some help with capturing the ZBuffer of active viewport(as rendered with ShowZBuffer command) in C#.

I could get the plain image capture after switching to ZBuffer renderer in Rhino…

    Rhino.Display.RhinoView view = doc.Views.ActiveView;

    if (Save)
      // Switch to ZBuffer
      Rhino.RhinoApp.RunScript("ShowZBuffer", false);
      // Capture to file
      Bitmap image = view.CaptureToBitmap();
      // Switch out of ZBuffer
      Rhino.RhinoApp.RunScript("ShowZBuffer", false);

…but is there a way to capture the ZBuffer without actually displaying it?

Rhino.Display.ZBufferCapture class compared to ViewCapture doesn’t contain any CaptureToBitmap method, so I am a bit lost now. But I have to admit that I have little experience with C# and Rhino namespace, so it could be a very simple thing I am missing here.

Can’t test this right now but ZBufferCapture has a “GrayscaleDib” Method that returns a bitmap — perhaps this is what you need?

Nice, seems like this might be it.
Unfortunately GrayscaleDib() gives me an error.

error: A generic error occurred in GDI+. (line:0)

capture_view.gh (5.7 KB)

Hi, have You solved the issue? I am interested in the ZBuffer view Capture

Nope, havent looked into it since. The snippet from the original post still works though, at least if you are okay with dumb-but-working solution.

Thanks for answering, I have found another script in VB that works for this

it might be the issue with the PATH. Try changing the slash to . It works for me.

1 Like