Saves an image to BMP, GIF, JPEG, PNG, TIF and other image file formats.
SAVEIMAGE("filename", "format", "pixformat", series, overwrite)
"filename" |
- |
A string, the name of the target image file. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"format" |
- |
Optional. A string, the destination image file format. Defaults to the source file extension if omitted or empty. Supports the following formats:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"pixformat" |
- |
Optional. A string, the destination image pixel format. Defaults to "PBGRA32" (32-bit premultiplied BGRA) if omitted or empty. Supports the following pixel formats:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
series |
- |
Optional. A series or window, the image to save. Defaults to the current window. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
overwrite |
- |
Optional. An integer, the overwrite mode:
|
An integer, 1 if successful, < 0 if failure.
W1: readimage(gethome + "data\mandrill.bmp")
saveimage(getmiscpath(1, 1) + "mandrill.png", w1, 1);
W2: readimage(getmiscpath(1, 1) + "mandrill.png")
W1 reads and displays the bitmap image file "mandrill.bmp".
SAVEIMAGE saves the image as a PNG file as determined by the "png" file extension. The existing file, if any, is overwritten.
W2 loads the PNG file. The image is the same as W1.

W3: readimage(gethome + "data\mandrill.bmp")
saveimage(getmiscpath(1, 1) + "mandrill.tif", "", "Gray8", w3, 1);
W4: readimage(getmiscpath(1, 1) + "mandrill.tif", "Gray8")

Same as above except, the image is saved as an 8-bit (0-255) grayscale TIFF file. Since READIMAGE normally returns a 24-bit RGBIMAGE, the pixel format is specified as "Gray8" to obtain a 0-255 grayscale image.
W3: spline2(randn(10), 10);setplottype(3);turbo
saveimage(getmiscpath(1, 1) + "density.png", w3, 1);
W4: readimage(getmiscpath(1, 1) + "density.png")
W3 creates a density plot by 2D cubic spline interpolation of a 10x10 random matrix, The resulting image is 91x91 and shaded using the TURBO color scheme.
SAVEIMAGE saves the density plot as a JPG file. The existing file if any, is overwritten.
W4 loads the JPG file. The image is the same as W3.
SAVEIMAGE saves an image from a window or series to a variety of image file formats.
By default, the type of saved image is determined by the filename extension. Current supported extensions include BMP, GIF, JPG, PNG and TIF.
See READIMAGE to load an image file.