ViewCapture() with 2x high-res does not seem right

Hi, I have a C# component that has preview overrides, and I’m trying to export a screen capture with a 2x bigger size. The 3D geometry looks correct, they are just there with the right size with thinner edge lines.
However, the 2D texts do not seem correct. They seem duplicated by 2x2.

I attach a code sample reproducing this issue. If somebody knows of a workaround, please let me know.previewtest.gh (3.2 KB)

Please somebody help! I need to create a high-res animation based on screen captures of Rhino screen.

I’ve run into this issue as well, afraid I don’t have a solution. My workaround has been to use the highest resolution monitor available, and run Rhino in fullscreen while capturing. That can get you close to 4K output.

Thanks Anders!

Here are my findings.
Though I didn’t have a 4K display, I tried several ideas, virtual desktop, connecting 3 monitors etc. None of them worked.
Simply it seems like this is not a C#/RhinoCommon issue, because ViewCaptureCommand replicates the same issue.

Finally, I found a workaround. It seems like this is a multifunction related to the screen dpi. The CaptureToBitmap accepts ViewCaptureSettings as an options provider. There, you can set a higher dpi. This way, the texts will get smaller. But anyway there are no duplicates any longer.

3200x2000 screengrab taken on a laptop with limited screen size.

2 Likes

That’s awesome, thanks for sharing. Will be very useful going forward :raised_hands:

nice trick @mikity_kogekoge! why I only obtain wires and not the current display mode?
Also, compare to viewcapturetofile, wires look jagged.
could this work with transparency too?

Hi, I notice several flaws.

  1. lines are Juggy
  2. point styles are wrong.

I searched a little bit and it seems like when ViewCapture.CaptureToBitmap(ViewCaptureSettings) is called OpenGL is disabled. That’s why duplicates of text does not happen. When ViewCapture.CaptureToBitmap(RhinoView) is called, OpenGL (and the current display mode) is used. In that case, texts are duplicated.

I think this is a bug and only McNeal can fix.

1 Like

So, probably the best workaround at this moment is to draw texts manually by surfaces.

Rhino.DocObjects.Font.FontStyle fontStyle = Rhino.DocObjects.Font.FontStyle.Upright;
    Rhino.DocObjects.Font.FontWeight fontWeight = Rhino.DocObjects.Font.FontWeight.Normal;
    Rhino.DocObjects.DimensionStyle dimstyle = new Rhino.DocObjects.DimensionStyle();
    double smallCapsScale = 1;
    double spacing = 0;
    bool underlined = false;
    bool strikethrough = false;
    Rhino.DocObjects.Font font = new Rhino.DocObjects.Font("Arial", fontWeight, fontStyle, underlined, strikethrough);

    var camera = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.MainViewport;
    var screenrect = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ScreenRectangle;
    var topleft = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.MainViewport.ClientToWorld(new System.Drawing.Point(screenrect.Left, screenrect.Top));
    var topright = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.MainViewport.ClientToWorld(new System.Drawing.Point(screenrect.Right, screenrect.Top));
    var bottomleft = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.MainViewport.ClientToWorld(new System.Drawing.Point(screenrect.Left, screenrect.Bottom));
    var bottomright = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.MainViewport.ClientToWorld(new System.Drawing.Point(screenrect.Right, screenrect.Bottom));

    double height = topleft.MinimumDistanceTo(bottomleft);
    double width = topleft.MinimumDistanceTo(topright);

    double size = height * 0.02;
    dimstyle.TextHeight = size;

    Plane pln;
    camera.GetCameraFrame(out pln);
    var dist = pln.Origin.DistanceTo(Point3d.Origin);
    Plane newpln = new Plane(camera.CameraTarget - pln.XAxis * width * (0.5 - 0.05) + pln.YAxis * height * (0.5 - 0.05), pln.ZAxis);
    Rhino.Geometry.TextEntity text_entity = new TextEntity
      {
        Plane = newpln,
        PlainText = text,
        Justification = TextJustification.MiddleCenter,
        Font = font
        };

    var tt = text_entity.CreateSurfaces(dimstyle, smallCapsScale, spacing);

    foreach(var s in tt)
      args.Display.DrawBrepShaded(s, new Rhino.Display.DisplayMaterial(System.Drawing.Color.FromArgb(15, 15, 15)));
1 Like

This part

needs to be

Plane newpln = new Plane(camera.CameraTarget - pln.XAxis * width * (0.5 - 0.05) + pln.YAxis * height * (0.5 - 0.05), pln.XAxis, pln.YAxis);