How to save an image from ETO?

Hi @dale

Do you know how I save out an image from the ETO?
I have a script that makes a sunstudy, but I could not figure out how to save that to a JPG or PNG.

It’s based on stuff from here :slight_smile:

Here’s what I do: I grab the view and alter the colors:

HI @Holo, after you captured and clicked the Close button, below will ask to save as png file:

def TestSampleEtoViewCaptureDialog():
    dialog = SampleEtoViewCaptureDialog();
    rc = dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)
    if (rc):
        
        # get the bitmap from the dialog
        bitmap = dialog.Image()
        if not isinstance(bitmap, Eto.Drawing.Bitmap): return
        
        # prompt for file path
        filename = rs.SaveFileName ("Save", "PNG Files (*.png)|*.png||")
        if not filename: return
        
        # save it
        bitmap.Save(filename, Eto.Drawing.ImageFormat.Png)
        print "Bitmap written to: {}".format(filename)

You can also run this code from a button while the dialog is open of course.

_
c.

Man, you just saved my day!!! Thanks a LOT!
I was so close… but still hours of trying to get it right didn’t get me the result, so thank you!!!

1 Like