Shiny Language Reference

Language Reference > Image Functions


saveimagebmp

bool saveimagebmp(image MyImage, string Filename);

 

 

Saves the specified image to a file

Experimental. The SAVEIMAGEBMP statement saves the specified image to the specified filename in bitmap format (*.bmp). This statement has been included for future expansion of the Shiny language however is available for use immediately. An example use could be to load an image, rotate and scale it, then use this statement to save it back to disk.

Note that you are responsible for naming the file correctly, i.e.: with a ".bmp" extension. You may name the file anything you like, but the image will always be saved in an uncompressed BMP format. For compressed formats, refer to saveimagejpg. Note that the bitdepth of the image will be automatically reduced to 24bits, even though 32bpp bitmap files are possible. To save a 32bit image (an image with per-pixel alpha values) refer to saveimagepng.

Although this statement is experimental, plugin developers can take advantage of it immediately. Any changes to the operation of this statement will not affect any plugins that use it.

 

Parameters

MyImage

A variable declared as type IMAGE and previously associated with a bitmap image using the CREATEIMAGE statement.

Filename

The path and filename to save the image to. You are responsible for validating this value, as well as providing a .bmp extension.

 

Return Value

True if saving succeeded, otherwise False. Saving can fail in limited circumstances, for example when the image format is incompatible with the bitmap filetype, or the specified path and filename is invalid. At this time further behaviour is undefined as this feature is experimental.

 

Example Code

image MyImage;
if(createimage(MyImage, "C:\\MyBitmap.bmp") == TRUE)
{
    // Invert the image
    invertimage(MyImage);

    // Save it back to disk
    saveimagebmp(MyImage, "C:\\MyBitmapInverted.bmp");
}