WinXDrawImage


hElement = WinXDrawImage (hWnd, hImage, x, y, w, h, xSrc, ySrc, blend)

Draws an image

Parameter Description
hWnd The handle to the window to draw the image on
hImage The handle to the image to draw
x The x coordinate of the upper left hand corner of the drawn image
y The y coordinate of the upper left hand corner of the drawn image
w The number of pixels horizontally to draw
h The number of pixels vertically to draw
xSrc The x coordinate of the source rectangle
ySrc The y coordinate of the source rectangle
blend $$TRUE to alpha blend the image, $$FALSE not to

Returns

The id of the drawn image or -1 on fail

Remarks

If you register the onPaint callback, this function has no effect. The image will not be visible untill you call the WinXUpdate function. You can use the id returned by this function to undo the image with the WinXUndo function.

This function copies a rectangle from the image to the specified window. The xSrc and ySrc parameters describe where this rectangle comes from on the source image. You can use these parameters, along with the w and h parameters to draw only part of an image. This allows you to store several graphical elements in a single image.

To use alpha blending you must first premultiply the image with the WinXDraw_PremultiplyImage function.

Examples

'load an image and draw it
extensions$ = "Bitmap Files (*.bmp)\0*.bmp\0All Files (*.*)\0*.*\0\0"
fileName$ = WinXDialog_OpenFile$ (#hMain, "Open Bitmap", extensions$, "", $$FALSE)
hImage = WinXDraw_LoadImage (fileName$, $$FILETYPE_WINBMP)
WinXDraw_GetImageInfo (hImage, @w, @h, @pBits)
WinXDrawImage (#hMain, hImage, 0, 0, w, h, 0, 0, $$FALSE)

Related Links

WinXDraw_CreateImage
WinXDraw_LoadImage
WinXDraw_Snapshot
WinXDraw_ResizeImage
WinXDraw_SetImagePixel
WinXDraw_SetConstantAlpha
WinXDraw_SetImageChannel
WinXDraw_GetImageInfo
WinXDraw_PremultiplyImage