This module defines some functions that can be used to save the OpenGL rendering and the pyFormex GUI to image files. There are even provisions for automatic saving to a series of files and creating a movie from these images.
) |
) |
image formats are lower case strings as 'png', 'gif', 'ppm', 'eps', etc. The available image formats are derived from the installed software.
fmt,verbose=False) |
Returns the image format, or None if it is not OK.
ext) |
The extension may or may not have an initial dot and may be in upper or lower case. The format is equal to the extension characters in lower case. If the supplied extension is empty, the default format 'png' is returned.
canvas,fn,fmt='png',options=None) |
canvas specifies the qtcanvas rendering window. fn is the name of the file fmt is the image file format
filename,format,windowname=None) |
This function needs a filename AND format. If a window is specified, the named window is saved. Else, the main pyFormex window is saved.
filename,format,border=False) |
This function needs a filename AND format. This is an alternative for save_window, by grabbin it from the root window, using save_rect. This allows us to grab the border as well.
x,y,w,h,filename,format) |
filename=None,window=False,multi=False,hotkey=True,autosave=False,border=False,rootcrop=False,format=None,verbose=False) |
With a filename and multi==False (default), the current viewport rendering is saved to the named file.
With a filename and multi==True, multisave mode is started. Without a filename, multisave mode is turned off. Two subsequent calls starting multisave mode without an intermediate call to turn it off, do not cause an error. The first multisave mode will implicitely be ended before starting the second.
In multisave mode, each call to saveNext() will save an image to the next generated file name. Filenames are generated by incrementing a numeric part of the name. If the supplied filename (after removing the extension) has a trailing numeric part, subsequent images will be numbered continuing from this number. Otherwise a numeric part '-000' will be added to the filename.
If window is True, the full pyFormex window is saved. If window and border are True, the window decorations will be included. If window is False, only the current canvas viewport is saved.
If hotkey is True, a new image will be saved by hitting the 'S' key. If autosave is True, a new image will be saved on each execution of the 'draw' function. If neither hotkey nor autosave are True, images can only be saved by executing the saveNext() function from a script.
If no format is specified, it is derived from the filename extension. fmt should be one of the valid formats as returned by imageFormats()
If verbose=True, error/warnings are activated. This is usually done when this function is called from the GUI.
) |
This is a quiet function that does nothing if multisave was not activated. It can thus safely be called on regular places in scripts where one would like to have a saved image and then either activate the multisave mode or not.
fn,size=32) |
) |
Use this function instead of directly accessing the autosave variable.
) |
filename,format,windowname=None) |