Cr�e table de couleur RVB � partir d'un tableau de couleur sp�cifi�
#include <WinAPIGdi.au3>
_WinAPI_CreateDIBColorTable ( Const ByRef $aColorTable [, $iStart = 0 [, $iEnd = -1]] )
$aColorTable | Le tableau de couleurs, en RVB, qui va servir � cr�er la table de couleur du DIB. |
$iStart | [optionnel] L'index du tableau o� commencer la cr�ation. |
$iEnd | [optionnel] L'index du tableau o� cesse la cr�ation. |
Succ�s: | Retourne une structure "dword[n]" qui repr�sente la table de couleur du DIB. |
�chec: | D�finit @error <> 0. |
La table de couleur cr��e par cette fonction est g�n�ralement utilis� dans les fonctions _WinAPI_CreateDIB() et _WinAPI_CreateDIBSection() pour cr�er un bitmap ind�pendant du p�riph�rique (DIB) avec 1, 4, ou 8 bits par pixel.
_WinAPI_CreateDIB, _WinAPI_CreateDIBSection
#include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIGdiDC.au3> #include <WinAPIHObj.au3> #include <WinAPIMem.au3> #include <WinAPIMisc.au3> ; Cr�e un tableau de couleur de 256 entr�es n�cessaire pour un bitmap de 8 bits par pixel Local $aColorTable[256] For $i = 0 To 255 $aColorTable[$i] = _WinAPI_RGB(0, $i, 255 - $i) Next ; Cr�e la table de couleur � partir du tableau de couleur Local $tColorTable = _WinAPI_CreateDIBColorTable($aColorTable) ; Cr�e un bitmap ind�pendant du p�riph�rique (DIB) de 8 bits par pixel and r�cup�re un pointeur sur la position de ses valeurs de bit Local $hBitmap = _WinAPI_CreateDIB(256, 256, 8, $tColorTable, 256) Local $pBits = _WinAPI_GetExtended() ; Remplit les index des couleurs du bitmap For $i = 0 To 255 _WinAPI_FillMemory($pBits + 256 * $i, 256, $i) Next ; Cr�e une GUI Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 256, 256) Local $idPic = GUICtrlCreatePic('', 0, 0, 256, 256) Local $hPic = GUICtrlGetHandle($idPic) ; Cr�e un bitmap DDB � partir d'un bitmap DIB pour un affichage correct dans le contr�le Local $hDC = _WinAPI_GetDC($hPic) Local $hDev = _WinAPI_CreateCompatibleBitmap($hDC, 256, 256) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hDev) _WinAPI_DrawBitmap($hMemDC, 0, 0, $hBitmap) _WinAPI_ReleaseDC($hPic, $hDC) _WinAPI_SelectObject($hMemDC, $hMemSv) _WinAPI_DeleteDC($hMemDC) ; D�finit le bitmap du contr�le $hPic _SendMessage($hPic, $STM_SETIMAGE, 0, $hDev) Local $hObj = _SendMessage($hPic, $STM_GETIMAGE) If $hObj <> $hDev Then _WinAPI_DeleteObject($hDev) EndIf ; Affiche la GUI GUISetState(@SW_SHOW) ; Sauvegarde le bitmap 8 bits par pixel dans un fichier .bmp Local $sPath = FileSaveDialog('Save Image', @TempDir, 'Bitmap Image Files (*.bmp)', 2 + 16, 'MyImage.bmp', $hForm) If $sPath Then _WinAPI_SaveHBITMAPToFile($sPath, $hBitmap, 2834, 2834) EndIf Do Until GUIGetMsg() = $GUI_EVENT_CLOSE