Shiny Language Reference
Language Reference > Image Functions
drawimage
bool drawimage(image MyImage, int X, int Y);
bool drawimage(image MyImage, int X, int Y, int Width, int Height);
Draws the specified image in the display panel
DRAWIMAGE draws the specified image into the display panel at the specified X,Y coordinates (0, 0 is considered the top left corner of the panel). The image variable must have previously been associated with an image using the CREATEIMAGE statement. DRAWIMAGE can optionally scale the image to fit in the rectangle specified by X, Y, Width, Height. The image can be scaled up as well as down, and scaling can be non-proportional. If no Width or Height parameter is supplied the image is rendered at its original (default) size.
This statement is only valid in the Render handler, or in a control callback drawing function.
Parameters
MyImage
A variable declared as type IMAGE and previously associated with a bitmap image using the CREATEIMAGE statement.
X
The X position to render the image at. 0 is the top left corner of the display panel.
Y
The Y position to render the image at. 0 is the top left corner of the display panel.
Width
An optional scaling width in pixels. The image will be scaled up or down to ensure its width matches this value.
Height
An optional scaling height in pixels. The image will be scaled up or down to ensure its height matches this value.
Return Value
TRUE if the rendering of the image was successful, otherwise FALSE. If DRAWIMAGE is passed an IMAGE variable that hasn't been associated with a bitmap, FALSE will always be returned and no drawing will be attempted. If DRAWIMAGE is called outside of the Render handler, FALSE will always be returned and no drawing will be attempted.
Example Code
image MyImage;
if(createimage(MyImage, "C:\\MyBitmap.bmp") == TRUE)
{
// Draw the image 20 pixels from the left, 10 pixels from the top
drawimage(MyImage, 20, 10);
// Draw the image in the same position, scaled to 50x50 pixels
drawimage(MyImage, 20, 10, 50, 50);
}