CanvasDrawBitmap

int CanvasDrawBitmap (int panelHandle, int controlID, int bitmapID, Rect sourceRect, Rect destinationRect);

Purpose

Draws a bitmap image, or portion thereof, in the destination rectangle that you specify on a canvas control.

Example

The following code copies a bitmap image, without any stretching or shrinking, to the canvas control, starting 20 pixels below the top edge of the canvas, and 30 pixels to the right of left edge of the canvas:

CanvasDrawBitmap (panelHandle, controlID, bitmapID, VAL_ENTIRE_OBJECT, MakeRect(20,30, VAL_KEEP_SAME_SIZE, VAL_KEEP_SAME_SIZE));

Parameters

Input
Name Type Description
panelHandle integer Specifier for a particular panel that is currently in memory. You obtain this handle from LoadPanel, NewPanel, or DuplicatePanel.
controlID integer The defined constant, located in the .uir header file, that you assigned to the control in the User Interface Editor, or the ID returned by NewCtrl or DuplicateCtrl.
bitmapID integer ID of the bitmap object that contains the image. Obtain the ID from NewBitmapEx, GetBitmapFromFile, GetCtrlBitmap, ClipboardGetBitmap, GetCtrlDisplayBitmap, GetPanelDisplayBitmap, GetScaledPanelDisplayBitmap, GetScaledCtrlDisplayBitmap, or DuplicateBitmap.
sourceRect Rect Rect structure specifying the portion of the bitmap to draw. The values are in terms of the pixel coordinates of the bitmap. The origin (0,0) is at the upper left corner of the bitmap.

The Rect structure is defined as follows:

typedef struct
   {
   int top;
   int left;
   int height;
   int width;
   } Rect;

You can create a Rect without having to declare a variable by using the following function:

Rect MakeRect (int top, int left, int height, int width);

Use VAL_ENTIRE_OBJECT to specify the entire image.

Example

CanvasDrawBitmap (panelHandle, controlID, bitmapID, VAL_ENTIRE_OBJECT, destinationRect);

destinationRect Rect Rect structure specifying the size and location of the area in which to draw the bitmap image on the canvas control. If sourceRect and destinationRect are not the same size, the bitmap stretches or shrinks to fit.

The Rect structure is defined as follows:

typedef struct
   {
   int top;
   int left;
   int height;
   int width;
   } Rect;

You can create a Rect without having to declare a variable by using the following function:

Rect MakeRect (int top, int left, int height, int width);

Use VAL_ENTIRE_OBJECT to specify the entire image.

If you want the bitmap to stretch to fit the size of the canvas, pass VAL_ENTIRE_OBJECT as destinationRect.

Example

CanvasDrawBitmap (panelHandle, controlID, bitmapID, sourceRectangle, MakeRect(20,30, VAL_KEEP_SAME_SIZE, VAL_KEEP_SAME_SIZE));

Return Value

Name Type Description
status integer Return value indicating whether the function was successful. A negative number indicates that an error occurred.

Code Error Message String
xx Success