Shiny Language Reference

Language Reference > Image Functions


resizeimage

resizeimage(image MyImage, int Width, int Height[, int Filter]);

 

 

Internally resizes the specified image

The RESIZEIMAGE statement internally resizes an image previously loaded with the createimage statement. By default RESIZEIMAGE uses bilinear filtering.

RESIZEIMAGE discards the original sized image and replaces it with the resized image. Therefore all subsequent calls to drawimage that use this image will use its resized form.

Resizing is a slow operation (especially when per-pixel alpha channel images are used), therefore you should use this statement as little as possible. If your plugin needs to draw 2 versions of the same image - one resized, and one normal - then you should load the image twice into 2 separate IMAGE variables, rather than resizing the image, drawing it, then resizing it back. Note that due to "sampling" (the technique used to smooth images when scaling up and down), resizing any image multiple times will adversely affect the quality of the image.

Using RESIZEIMAGE will produce the same visual effect as specifying a width and height parameter when drawing an image using drawimage. However if you need to draw the same image at a different size repeatedly, it is more efficient to use RESIZEIMAGE to set the image's desired dimensions, then use drawimage without a width and height parameter. This is because RESIZEIMAGE acts directly on the loaded image, whereas drawimage must perform the resize each time it is called.

 

Parameters

MyImage

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

Width

The new pixel width of the image. You can use this statement to increase or decrease the dimensions of an image.

Height

The new pixel height of the image. You can use this statement to increase or decrease the dimensions of an image.

Filter

Optional. The type of filter to use when resizing, by default this is set to FILTER_BILINEAR. The following defines are recognised internally within SSEdit and the Shiny compiler. A Google search will produce lots of results with sample images to help compare the differences between the filters. Most plugins will use FILTER_BILINEAR as standard, FILTER_BOX where speed is an issue and quality is not, and FILTER_BICUBIC where speed is not an issue but quality is.

SSEdit #define Integer Value Filter type
FILTER_BOX 0 Standard box filtering (fastest, lowest quality)
FILTER_BILINEAR 1 Bilinear filtering (fast, good quality)
FILTER_BSPLINE 2 Cubic b-spline filtering (slow, excellent quality)
FILTER_BICUBIC 3 Bicubic filtering (slow, excellent quality)
FILTER_CATMULLROM 4 Catmull-Rom filtering (very slow, best quality)

Return Value

None

 

Example Code

image MyImage;
if(createimage(MyImage, "C:\\MyBitmap.bmp") == TRUE)
{
    // Resize the image to 50 pixels wide, 20 pixels high
    resizeimage(MyImage, 50, 20);

    // Resize the image using bicubic filtering
    resizeimage(MyImage, 50, 20, FILTER_BICUBIC);
}