ViewCapture Display Mode

I am using Rhino.Display.ViewCapture.CaptureToBitmap(ViewCaptureSetting) to capture high resolution screenshot of a model. I remember when I was running this method before the most recent Rhino update, the display mode for the view capture follows my active viewport display mode. However, now the image is always in wireframe mode. Is there a way to specify the display model in the ViewCaptureSetting?

Thanks,

Hi @AlanTai,

This sample seems to work. Let me know if you find otherwise.

SampleCsViewCapture.cs

– Dale

Dale,

The example works.
However, I want to control the dpi and boundary of the image and use the static method Rhino.Display.ViewCapture.CaptureToBitmap(ViewCaptureSetting).This method is now always capturing the image in wireframe mode. Is there a way to specify dpi using Rhino.Display.ViewCapture.CaptureToBitmap(RhinoView) method? Thanks.


Directory.CreateDirectory(targetFolder);
Rhino.Display.RhinoView currView = RhinoDoc.ActiveDoc.Views.ActiveView;
Rhino.Display.RhinoViewport currViewPort = currView.ActiveViewport;

Rhino.Geometry.BoundingBox bb = geo.GetBoundingBox(false);
currViewPort.ZoomBoundingBox(bb);

double width = (bb.Max - bb.Min).X + 10;
double height = (bb.Max - bb.Min).Y + 10;
double dpi = 100;

Rhino.Display.ViewCaptureSettings setting = new Rhino.Display.ViewCaptureSettings(currView, new Size((int) (width * dpi), (int) (height * dpi)), dpi);
System.Drawing.Bitmap bitmap = Rhino.Display.ViewCapture.CaptureToBitmap(setting);
    bitmap.Save(targetFolder + name + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

Hi @AlanTai,

If I am not mistaken, the static function you are calling always outputs vectors. Thus you’ll always get wireframe. This method is primarily used for printing to PDF or SVG.

Is there a reason you don’t just modify the sample I referenced, which does an actual “view capture”?

– Dale

Dale,

That static method was working for me. It did output bitmap image in shaded mode. I think it is not working after I update my Rhino to the latest version, but I am not 100% sure.

I need my image size to adjust to the objects bounding box and also at the correct pixel per inch. For example, if the object is 10"x20" in top view, I want the image to be 1000px x 2000px. So 100px=1" in the image. I can specify both the size and dpi in ViewCaptureSetting and use Rhino.Display.ViewCapture.CaptureToBitmap(ViewCaptureSetting) to capture the image in the correct size. I do not know how to achieve the same result with Rhino.Display.ViewCapture.CaptureToBitmap(RhinoView).

Thanks,

Dale,

I found the solution.
In Rhino 6 SR29, one of the bug fix is: ViewCaptureSettings RasterMode = False should return VCS in wireframe (RH059034). Since, the default value for RasterMode is false, ViewCaptureSettings will default to wireframe mode after SR29. If I set RasterMode=true, the image captured can be in the display mode of the viewport.

1 Like