Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all articles
Browse latest Browse all 8543

Capture Image Inside Task

$
0
0

I have this method that captures an image and saves it in a location:

    public void SaveImage()
    {
        string ImageName = @"C:\";
        var doc = Rhino.RhinoDoc.ActiveDoc;
        var view = doc.Views.ActiveView;
        var view_capture = new ViewCapture
        {
            Width = view.ActiveViewport.Size.Width,
            Height = view.ActiveViewport.Size.Height,
            ScaleScreenItems = false,
            DrawAxes = false,
            DrawGrid = false,
            DrawGridAxes = false,
            TransparentBackground = true
        };
        var bitmap = view_capture.CaptureToBitmap(view);
        if (null != bitmap)
        {
            bitmap.Save(ImageName, System.Drawing.Imaging.ImageFormat.Png);
            bitmap.Dispose();
        }
    }

This method works beautifully, but it also takes a little time to execute this method, it is only a little bit but it affects the following functions.

My solution is to run this method within a task: Task.Run(() => saveMat.SaveImage());

Runing with Task, popup “Exception Error”:

I’m not able to find out where this error comes from and why, any ideas?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 8543

Trending Articles