Hi!
There is no an easy way to save the generated canvas image to a file directly. In theory the Graphics class in GDI+ allows copying graphics to a bitmap, which, in turn, can be saved into a file. In practice, however, it did not work last time I tried it.
There is another easy way to save a screenshot of the entire screen (at any runtime moment) with a dedicated command. In order to do it:
- Go to the Experiment ribbon tab.
- In the Properties panel find the 'Save Screenshot Now' property and create a proxy variable bound to it.
- Use the following code in a snippet that is invoked right after the updated canvas is rendered on the screen:
SaveScreenshotNow=@"C:\MyData\Stimuli_"+StimulusNumber+".jpg"; /* StimulusNumber represents some stimulus id.*/
A couple of remarks on the above procedure:
You should not use SaveScreenshotNow in the same snippet, in which GraphicsClass does rendering procedures. Instead, you have to wait until the new rendering is presented on the screen, which typically happens automatically after the 'rendering' snippet call. Thus, the best place for the SaveScreenshotNow command is the next snippet in a timeline, given that the target event (one containing the GDI Canvas element) is active. If you do rendering in advance, then wait until the onset of the target event to make a screenshot.
In the newest version of EventIDE, you need to apply rendering updates on the GDI Canvas Element manually, by calling 'UpdateCanvasNow=true;', right after the rendering procedures. The 'Update Canvas Now' is a new command property of the GDI canvas element.
I hope you find the above useful. Please contact me directly, if you need more details or any help.