Saving bitmap to file using Rhinocommon

I’ve seen ways to create a bitmap file, such as the answers to this thread:

But I can’t seem to find the direct command to save that bitmap file to a specified folder in my computer. What commands would I use to accomplish my task?

BitMap bm = view.CaptureToBitmap(new Size(600,800));
bm.Save(@"C:\path\to\bitmapfile.bmp");
1 Like

I tried that, but this seems to be a persistent error:

“A generic error occurred in GDI
http://stackoverflow.com/questions/1053052/a-generic-error-occurred-in-gdi-jpeg-image-to-memorystream

My code (“Output” is a a custom class):

Rhino.Display.RhinoView View = doc.Views.ActiveView;
var bitmap = View.CaptureToBitmap(new Size(480, 480));
try
{
bitmap.Save(@“C:\test” + current + “.jpeg”, ImageFormat.Jpeg);
}
catch (Exception e)
{
Output.ToRhinoConsole(e.Message);
Output.ToRhinoConsole(e.StackTrace);
}

I also tried:

Rhino.Display.RhinoView View = doc.Views.Add(“Snapshot” +
current, Rhino.Display.DefinedViewportProjection.Perspective, new Rectangle(
0, 0, 480, 480), false);

What can I do to fix this error?

Do you have write access on the file c:\testcurrent.jpg?
You are trying to write to the c: root folder,

Yes that was the problem! I couldn’t directly add any files to the root
folder without my admin password. Thanks!