Effectue un transfert de bloc de bits des données de couleur correspondant à un rectangle de pixels
#include <WinAPIGdi.au3>
_WinAPI_TransparentBlt ( $hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iRGB )
$hDestDC | Handle du contexte de périphérique de destination. |
$iXDest | La coordonnée x, en unités logiques, du coin supérieur gauche du rectangle de destination. |
$iYDest | La coordonnée y, en unités logiques, du coin supérieur gauche du rectangle de destination. |
$iWidthDest | La largeur, en unités logiques, du rectangle de destination. |
$iHeightDest | La hauteur, en unités logiques, du rectangle de destination. |
$hSrcDC | Handle du contexte de périphérique source. |
$iXSrc | La coordonnées x, en unités logiques, du coin supérieur gauche du rectangle source. |
$iYSrc | La coordonnée y, en unités logiques, du coin supérieur gauche du rectangle source. |
$iWidthSrc | La largeur, en unités logiques, du rectangle source. |
$iHeightSrc | La hauteur, en unités logiques, du rectangle source. |
$iRGB | La couleur RVB dans le bitmap source à traiter comme transparente. |
Succès: | Retourne True. |
Échec: | Retourne False. |
Si les rectangles source et destination n'ont pas la même taille, le bitmap source est étirée pour correspondre au rectangle de destination. Lorsque la fonction _WinAPI_SetStretchBltMode() est utilisée, les modes d'étirement $BLACKONWHITE et $WHITEONBLACK sont convertis en $COLORONCOLOR pour la fonction _WinAPI_TransparentBlt().
Cette fonction prend en charge tous les formats de bitmap source. Cependant, pour les bitmaps 32 bits par pixel, elle copie simplement la valeur alpha. Utilisez _WinAPI_AlphaBlend() pour spécifier des bitmaps 32 bits par pixel avec transparence.
_WinAPI_AlphaBlend, _WinAPI_SetStretchBltMode
Consultez GdiTransparentBlt dans la librairie MSDN.
#include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIGdiDC.au3> #include <WinAPIHObj.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> Local $a_idPic[2], $a_hPic[2], $a_hBitmap[2] ; Crée une GUI Local $hForm = GUICreate('Test '& StringReplace(@ScriptName, '.au3', '()'), 260, 140) $a_idPic[0] = GUICtrlCreatePic('', 20, 20, 100, 100) $a_idPic[1] = GUICtrlCreatePic('', 140, 20, 100, 100) For $i = 0 To 1 $a_hPic[$i] = GUICtrlGetHandle($a_idPic[$i]) Next ; Crée bitmap1 Local $hDC = _WinAPI_GetDC($a_hPic[0]) Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC) $a_hBitmap[0] = _WinAPI_CreateCompatibleBitmapEx($hDC, 100, 100, 0xFF00FF) Local $hDestSv = _WinAPI_SelectObject($hDestDC, $a_hBitmap[0]) Local $hObj = _WinAPI_CreateCompatibleBitmapEx($hDC, 70, 70, 0x00A060) _WinAPI_DrawBitmap($hDestDC, 15, 15, $hObj) _WinAPI_DeleteObject($hObj) $hObj = _WinAPI_CreateCompatibleBitmapEx($hDC, 40, 40, 0xFF00FF) _WinAPI_DrawBitmap($hDestDC, 30, 30, $hObj) _WinAPI_DeleteObject($hObj) _WinAPI_ReleaseDC($a_hPic[0], $hDC) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_DeleteDC($hDestDC) ; Crée bitmap2 $hDC = _WinAPI_GetDC($a_hPic[1]) $hDestDC = _WinAPI_CreateCompatibleDC($hDC) $a_hBitmap[1] = _WinAPI_CreateCompatibleBitmapEx($hDC, 100, 100, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE))) $hDestSv = _WinAPI_SelectObject($hDestDC, $a_hBitmap[1]) Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $a_hBitmap[0]) _WinAPI_TransparentBlt($hDestDC, 0, 0, 100, 100, $hSrcDC, 0, 0, 100, 100, 0xFF00FF) _WinAPI_ReleaseDC($a_hPic[1], $hDC) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_DeleteDC($hDestDC) _WinAPI_DeleteDC($hSrcDC) ; Place les deux bitmaps dans des contrôles Picture For $i = 0 To 1 _SendMessage($a_hPic[$i], $STM_SETIMAGE, 0, $a_hBitmap[$i]) $hObj = _SendMessage($a_hPic[$i], $STM_GETIMAGE) If $hObj <> $a_hBitmap[$i] Then _WinAPI_DeleteObject($a_hBitmap[$i]) EndIf Next GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE