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