Draws a bitmap into the specified device context
#include <WinAPIGdi.au3>
_WinAPI_DrawBitmap ( $hDC, $iX, $iY, $hBitmap [, $iRop = 0x00CC0020] )
$hDC | Handle to the device context into which the bitmap will be drawn. |
$iX | Specifies the logical x-coordinate of the upper-left corner of the bitmap. |
$iY | Specifies the logical y-coordinate of the upper-left corner of the bitmap. |
$hBitmap | Handle to the bitmap to be drawn. |
$iRop | [optional] The raster-operation code (same as for _WinAPI_BitBlt()). Default is $SRCCOPY. |
Success: | 1. |
Failure: | 0 and sets the @error flag to non-zero. |
This function does not support bitmaps with alpha channel, use _WinAPI_AlphaBlend() to work with them.
_WinAPI_AlphaBlend, _WinAPI_BitBlt
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIGdiDC.au3>
#include <WinAPIHObj.au3>
#include <WinAPIRes.au3>
#include <WindowsConstants.au3>
; Load image
Local $hSource = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Hatch.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $tSIZE = _WinAPI_GetBitmapDimension($hSource)
Local $W = DllStructGetData($tSIZE, 'X')
Local $H = DllStructGetData($tSIZE, 'Y')
; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
Local $idPic = GUICtrlCreatePic('', 0, 0, @DesktopWidth, @DesktopHeight)
Local $hPic = GUICtrlGetHandle($idPic)
; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, @DesktopWidth, @DesktopHeight)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
For $i = 0 To Ceiling(@DesktopWidth / $W) - 1
For $j = 0 To Ceiling(@DesktopHeight / $W) - 1
_WinAPI_DrawBitmap($hDestDC, $i * $W, $j * $H, $hSource)
Next
Next
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDestDC)
; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
_WinAPI_DeleteObject($hBitmap)
EndIf
GUISetState(@SW_SHOW)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE