wolf9228 Posted December 6, 2012 Posted December 6, 2012 FilesUntitled1.pngUntitled2.pngscript FilePaint.zipPaint.au3expandcollapse popup#include <Memory.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <Color.au3> Global $itagRGBQUAD = "BYTE rgbBlue;BYTE rgbGreen;BYTE rgbRed;BYTE rgbReserved" Global $RgbSize = DllStructGetSize(DllStructCreate($itagRGBQUAD)) _GDIPlus_Startup() $hImage1 = _GDIPlus_ImageLoadFromFile("Untitled1.png") $hImage2 = _GDIPlus_ImageLoadFromFile("Untitled2.png") $hBMP1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1) $hBMP2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage2) $BitsStruct1 = TransparentBmp($hBMP1,$hBMP2,MCArray(0x22B14C,0xED1C24)) $hBMP3 = BitsStructToBmp($BitsStruct1) $Bitmap = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP3) _GDIPlus_ImageSaveToFile ($Bitmap,@ScriptDir & "\NewImage1.png") _WinAPI_DeleteObject ($Bitmap) $BitsStruct2 = MergeBmp($hBMP2,$hBMP1,10,10) $hBMP4 = BitsStructToBmp($BitsStruct2) $Bitmap = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP4) _GDIPlus_ImageSaveToFile ($Bitmap,@ScriptDir & "\NewImage2.png") _WinAPI_DeleteObject ($Bitmap) _GDIPlus_ShutDown() Func TransparentBmp($FromBmp ,$ToBmp ,$Color ,$FBmpL = -1 ,$FBmpT = -1 ,$FBmpW = -1 ,$FBmpH = -1 _ ,$TBmpL = -1 ,$TBmpT = -1 ,$TBmpW =-1 ,$TBmpH = -1) if UBound($Color,0) <> 1 Then Return SetError(1,0,0) Local $yStBits = GetBitsStruct($FromBmp) if @error Then Return SetError(2,0,0) Local $yW = DllStructGetData($yStBits,"WIDTH") Local $yH = DllStructGetData($yStBits,"HEIGHT") Local $yRgbSize = DllStructGetData($yStBits,"SIZE") if ($FBmpL < 0) Then $FBmpL = 0 if ($FBmpT < 0) Then $FBmpT = 0 if ($FBmpW < 0) Then $FBmpW = $yW if ($FBmpH < 0) Then $FBmpH = $yH if (($FBmpL + $FBmpW) < 1) or (($FBmpL + $FBmpW) > $yW) Or (($FBmpT + $FBmpH) < 1) _ Or (($FBmpT + $FBmpH) > $yH) Then Return SetError(3,0,0) Local $xStBits = GetBitsStruct($ToBmp) if @error Then Return SetError(3,0,0) Local $xW = DllStructGetData($xStBits,"WIDTH") Local $xH = DllStructGetData($xStBits,"HEIGHT") Local $xRgbSize = DllStructGetData($xStBits,"SIZE") if ($TBmpL < 0) Then $TBmpL = 0 if ($TBmpT < 0) Then $TBmpT = 0 if ($TBmpW < 0) Then $TBmpW = $xW if ($TBmpH < 0) Then $TBmpH = $xH if (($TBmpL + $TBmpW) < 1) or (($TBmpL + $TBmpW) > $xW) Or (($TBmpT + $TBmpH) < 1) _ Or (($TBmpT + $TBmpH) > $xH) Then Return SetError(4,0,0) if ($xW > $yW) Or ($xH > $yH) Then Return SetError(5,0,0) Local $Rows = UBound($Color),$Dataz,$aColor,$iColor Local $Datax,$OutxStBitsPtr,$OutyStBitsPtr,$RGBQUADx Local $RGBQUADy,$xStBitsPtr,$yStBitsPtr if ($Rows > 1) Then For $q = 0 To ($Rows - 1) Local $aColor = _ColorGetRGB($Color[$q]) Local $iColor = DllStructCreate("BYTE RGB[3]") DllStructSetData($iColor,1,$aColor[2],1) DllStructSetData($iColor,1,$aColor[1],2) DllStructSetData($iColor,1,$aColor[0],3) $Color[$q] = DllStructGetData($iColor,1) Next $xStBitsPtr = DllStructGetPtr($xStBits,"RGBQUAD") $yStBitsPtr = DllStructGetPtr($yStBits,"RGBQUAD") For $i = $TBmpT To (($TBmpH + $TBmpT) - 1) For $j = $TBmpL To (($TBmpW + $TBmpL) - 1) $OutxStBitsPtr = $xStBitsPtr + (((($i + 1) * $xW) - ($xW - ($j + 1)) - 1) * $RgbSize) $OutyStBitsPtr = $yStBitsPtr + (((($i - $TBmpT + $FBmpT + 1) * $yW) - ($yW - ($j - $TBmpL + $FBmpL + 1)) - 1) * $RgbSize) $RGBQUADx = DllStructCreate("BYTE RGB[3]",$OutxStBitsPtr) $RGBQUADy = DllStructCreate("BYTE RGB[3]",$OutyStBitsPtr) $Datax = DllStructGetData($RGBQUADx,"RGB") For $q = 0 To ($Rows - 1) if ($Datax = $Color[$q]) Then DllStructSetData($RGBQUADx,"RGB",DllStructGetData($RGBQUADy,"RGB")) ExitLoop EndIf Next Next Next Else $aColor = _ColorGetRGB($Color[0]) $iColor = DllStructCreate("BYTE RGB[3]") DllStructSetData($iColor,1,$aColor[2],1) DllStructSetData($iColor,1,$aColor[1],2) DllStructSetData($iColor,1,$aColor[0],3) $Dataz = DllStructGetData($iColor,1) $xStBitsPtr = DllStructGetPtr($xStBits,"RGBQUAD") $yStBitsPtr = DllStructGetPtr($yStBits,"RGBQUAD") For $i = $TBmpT To (($TBmpH + $TBmpT) - 1) For $j = $TBmpL To (($TBmpW + $TBmpL) - 1) $OutxStBitsPtr = $xStBitsPtr + (((($i + 1) * $xW) - ($xW - ($j + 1)) - 1) * $RgbSize) $OutyStBitsPtr = $yStBitsPtr + (((($i - $TBmpT + $FBmpT + 1) * $yW) - ($yW - ($j - $TBmpL + $FBmpL + 1)) - 1) * $RgbSize) $RGBQUADx = DllStructCreate("BYTE RGB[3]",$OutxStBitsPtr) $RGBQUADy = DllStructCreate("BYTE RGB[3]",$OutyStBitsPtr) $Datax = DllStructGetData($RGBQUADx,"RGB") if ($Dataz = $Datax) Then DllStructSetData($RGBQUADx,"RGB",DllStructGetData($RGBQUADy,"RGB")) Next Next EndIf Return $xStBits EndFunc Func MergeBmp($FromhBmp,$TohBmp,$L = -1,$T = -1,$BkColor = 0xFFFFFF) Local $xStBits = GetBitsStruct($FromhBmp) if @error Then Return SetError(1,0,0) Local $xW = DllStructGetData($xStBits,"WIDTH") Local $xH = DllStructGetData($xStBits,"HEIGHT") Local $xRgbSize = DllStructGetData($xStBits,"SIZE") Local $yStBits = GetBitsStruct($TohBmp) if @error Then Return SetError(2,0,0) Local $yW = DllStructGetData($yStBits,"WIDTH") Local $yH = DllStructGetData($yStBits,"HEIGHT") Local $yRgbSize = DllStructGetData($yStBits,"SIZE") if ($L < 0) Then $L = 0 if ($T < 0) Then $T = 0 Select Case (($L + $xW) <= $yW) And (($T + $xH) <= $yH) Local $xColusCount = $xW For $RowIndex = 0 To ($xH - 1) Local $xStBPtr = GetPointerAtRowPos($xStBits,$RowIndex) ; Move Ptr To First BYTE Of Row => $RowIndex Local $yStBPtr = GetPointerAtRowPos($yStBits,($RowIndex + $T)) + ($L * $RgbSize) ; Move Ptr To First BYTE Of Row => ($RowIndex + $T) ; + ($L * $RgbSize) Move PointerAtRowPos From left to right + ($L * $RgbSize) _MemMoveMemory($xStBPtr,$yStBPtr,($RgbSize * ($xColusCount - 1))) ;Size Of One Row In $xStBits Next Return $yStBits Case Else Local $NewyW = $yW , $NewyH = $yH if (($L + $xW) > $yW) Then $NewyW = ($L + $xW) if (($T + $xH) > $yH) Then $NewyH = ($T + $xH) Local $ColorBmp = CreateCBmp($NewyW,$NewyH,$BkColor) if @error Then Return SetError(4,0,0) $nStBits = GetBitsStruct($ColorBmp) if @error Then _WinAPI_DeleteObject($ColorBmp) Return SetError(5,0,0) EndIf _WinAPI_DeleteObject($ColorBmp) $nRgbSize = DllStructGetData($nStBits,"SIZE") Local $yColusCount = $yW , $xColusCount = $xW For $RowIndex = 0 To ($NewyH - 1) if ($RowIndex < $yH) Then Local $yStBPtr = GetPointerAtRowPos($yStBits,$RowIndex) ; Move Ptr To First BYTE Of Row => $RowIndex Local $nStBPtr = GetPointerAtRowPos($nStBits,$RowIndex) ; Move Ptr To First BYTE Of Row => $RowIndex _MemMoveMemory($yStBPtr,$nStBPtr,($RgbSize * ($yColusCount - 1))) ;Size Of One Row In $yStBits EndIf If ($RowIndex < $xH) Then Local $xStBPtr = GetPointerAtRowPos($xStBits,$RowIndex) ; Move Ptr To First BYTE Of Row => $RowIndex Local $nStBPtr = GetPointerAtRowPos($nStBits,($RowIndex + $T)) + ($L * $RgbSize) ; Move Ptr To First BYTE Of Row => ($RowIndex + $T) ; + ($L * $RgbSize) Move PointerAtRowPos From left to right + ($L * $RgbSize) _MemMoveMemory($xStBPtr,$nStBPtr,($RgbSize * ($xColusCount - 1))) ;Size Of One Row In $xStBits EndIf Next Return $nStBits EndSelect EndFunc Func BitsStructToBmp($StBits) if Not IsDllStruct($StBits) Then Return SetError(1,0,0) Local $iW = DllStructGetData($StBits,"WIDTH") if @error Then Return SetError(2,0,0) Local $iH = DllStructGetData($StBits,"HEIGHT") if @error Then Return SetError(3,0,0) Local $mRgbSize = DllStructGetData($StBits,"SIZE") if @error Then Return SetError(4,0,0) $hBmp = CreateCBmp($iW,$iH) if @error Then Return SetError(5,0,0) SetBitmapBits($hBmp,$mRgbSize,DllStructGetPtr($StBits,"RGBQUAD")) if @error Then _WinAPI_DeleteObject($hBmp) Return SetError(6,0,0) EndIf Return $hBmp EndFunc Func GetBitsStruct( $hBmp , $L = -1 , $T = -1 , $W = -1 , $H = -1 ) Local $SizeArray = GetImageSize($hBmp) if @error Then Return SetError(1,0,0) Local $biWidth = $SizeArray[0] Local $biHeight = $SizeArray[1] if ($L < 0) Then $L = 0 if ($T < 0) Then $T = 0 if ($W < 0) Then $W = ($biWidth - $L) if ($H < 0) Then $H = ($biHeight - $T) if ($L >= $biWidth Or (($L + $W) > $biWidth)) Then $L = 0 if ($T >= $biHeight Or (($T + $H) > $biHeight)) Then $T = 0 Local $vRgbSize = ($RgbSize * ($biWidth * $biHeight)) Local $vStBits = DllStructCreate("INT WIDTH;INT HEIGHT;INT SIZE;BYTE RGBQUAD[" & ($vRgbSize) & "]") DllStructSetData($vStBits ,"WIDTH",$biWidth) DllStructSetData($vStBits,"HEIGHT",$biHeight) DllStructSetData($vStBits,"SIZE",$vRgbSize) GetBitmapBits($hBmp,DllStructGetPtr($vStBits,"RGBQUAD"),$vRgbSize) if @error Then Return SetError(2,0,0) if ($L = 0 And $T = 0 And $W = $biWidth And $H = $biHeight) Then Return $vStBits Local $nRgbSize = ($RgbSize * ($W * $H)) , $ColusCount = $W Local $nStBits = DllStructCreate("INT WIDTH;INT HEIGHT;INT SIZE;BYTE RGBQUAD[" & ($nRgbSize) & "]") DllStructSetData($nStBits ,"WIDTH",$W) DllStructSetData($nStBits,"HEIGHT",$H) DllStructSetData($nStBits,"SIZE",$nRgbSize) For $RowIndex = 0 To ($H - 1) Local $nStBPtr = GetPointerAtRowPos($nStBits,$RowIndex) ; Move Ptr To First BYTE Of Row => $RowIndex Local $vStBPtr = GetPointerAtRowPos($vStBits,($RowIndex + $T)) + ($L * $RgbSize) ; Move Ptr To First BYTE Of Row => ($RowIndex + $T) ; + ($L * $RgbSize) Move PointerAtRowPos From left to right + ($L * $RgbSize) _MemMoveMemory($vStBPtr,$nStBPtr,($RgbSize * ($ColusCount - 1))) ;Size Of One Row In $nStBPtr Next Return $nStBits EndFunc Func GetBitmapBits($hbmp,$lpvBits,$cbBuffer) $BytesNu = DllCall("Gdi32.dll","LONG","GetBitmapBits","ptr" _ ,$hbmp,"LONG",$cbBuffer,"ptr",$lpvBits) if @error Or Not($BytesNu[0]) Then SetError(1,0,0) Return SetError(0,0,$BytesNu[0]) EndFunc Func SetBitmapBits($hbmp,$cBytes,$lpBits) $BytesNu = DllCall("Gdi32.dll","long","SetBitmapBits","ptr",$hbmp , _ "DWORD",$cBytes,"ptr",$lpBits) if @error Or Not($BytesNu[0]) Then SetError(1,0,0) Return SetError(0,0,$BytesNu[0]) EndFunc Func GetPointerAtRowPos($StBits,$RowIndex) if Not IsDllStruct($StBits) Then Return SetError(1,0,0) Local $ColusCount = DllStructGetData($StBits,"WIDTH") Local $RowsCount = DllStructGetData($StBits,"HEIGHT") If ($RowIndex < 0 Or $RowIndex > ($RowsCount -1)) Then Return SetError(2,0,0) Local $StBitsPtr = DllStructGetPtr($StBits,"RGBQUAD") Local $PointerAtRowPos = ($StBitsPtr + (($RowIndex * $ColusCount) * $RgbSize)) Return $PointerAtRowPos EndFunc Func GetImageSize($hBmp) Local $ntagBITMAPINFO = "DWORD biSize;LONG biWidth;LONG biHeight;USHORT biPlanes;" & _ "USHORT biBitCount;DWORD biCompression;DWORD biSizeImage;LONG biXPelsPerMeter;" & _ "LONG biYPelsPerMeter;DWORD biClrUsed;DWORD biClrImportant;BYTE RGBQUAD[4]" Local $vBITMAPINFO = DllStructCreate($ntagBITMAPINFO) DllStructSetData($vBITMAPINFO,"biSize",(DllStructGetSize($vBITMAPINFO) - $RgbSize)) Local $hDC = _WinAPI_CreateCompatibleDC(0) if @error Then _WinAPI_DeleteDC($hDC) Return SetError(1,0,0) EndIf _WinAPI_GetDIBits($hDC,$hBmp,0,0,0,DllStructGetPtr($vBITMAPINFO),0) if @error Then _WinAPI_DeleteDC($hDC) Return SetError(2,0,0) EndIf Local $biWidth = DllStructGetData($vBITMAPINFO,"biWidth") Local $biHeight = DllStructGetData($vBITMAPINFO,"biHeight") Local $SizeArray[2] $SizeArray[0] = $biWidth $SizeArray[1] = $biHeight Return $SizeArray EndFunc Func CreateCBmp($width,$height,$BkColor = 0,$DeleteDC = True) $nDC = _WinAPI_GetDC(0) if @error Then Return SetError(1,0,0) $CompatibleDC = _WinAPI_CreateCompatibleDC($nDC) if @error Then _WinAPI_ReleaseDC(0,$nDC) Return SetError(2,0,0) EndIf $hBmp = _WinAPI_CreateCompatibleBitmap($nDC,$width,$height) if @error Then _WinAPI_DeleteDC($CompatibleDC) _WinAPI_ReleaseDC(0,$nDC) Return SetError(3,0,0) EndIf _WinAPI_SelectObject($CompatibleDC,$hBmp) if @error Then _WinAPI_DeleteObject($hBmp) _WinAPI_DeleteDC($CompatibleDC) _WinAPI_ReleaseDC(0,$nDC) Return SetError(4,0,0) EndIf Local $nBrush if ($BkColor) Then $nRect = DllStructCreate("int;int;int;int") DllStructSetData($nRect,1,0) DllStructSetData($nRect,2,0) DllStructSetData($nRect,3,$width) DllStructSetData($nRect,4,$height) $nBrush = _WinAPI_CreateSolidBrush($BkColor) If @error Then _WinAPI_DeleteObject($hBmp) _WinAPI_DeleteDC($CompatibleDC) _WinAPI_ReleaseDC(0,$nDC) Return SetError(5,0,0) EndIf _WinAPI_FillRect($CompatibleDC,$nRect,$nBrush) EndIf If @error Then _WinAPI_DeleteObject($nBrush) _WinAPI_DeleteObject($hBmp) _WinAPI_DeleteDC($CompatibleDC) _WinAPI_ReleaseDC(0,$nDC) Return SetError(6,0,0) EndIf _WinAPI_DeleteObject($nBrush) if ($DeleteDC) Then _WinAPI_DeleteDC($CompatibleDC) _WinAPI_ReleaseDC(0,$nDC) Return $hBmp Else Local $RtArray[3] $RtArray[0] = $hBmp $RtArray[1] = $nDC $RtArray[3] = $CompatibleDC Return $RtArray EndIf EndFunc Func MCArray($Col1,$Col2=0,$Col3=0,$Col4=0,$Col5=0,$Col6=0,$Col7=0,$Col8=0,$Col9=0,$Col10=0 _ ,$Col11=0,$Col12=0,$Col13=0,$Col14=0,$Col15=0,$Col16=0,$Col17=0,$Col18=0,$Col19=0,$Col20=0) Local $ColorsArray[@NumParams] For $i = 0 To (@NumParams - 1) $ColorsArray[$i] = Eval("Col" & ($i + 1)) Next Return $ColorsArray EndFunc صرح السماء كان هنا
UEZ Posted December 6, 2012 Posted December 6, 2012 (edited) Nice approach but it can be done also with pure GDI+ only: expandcollapse popup;coded by UEZ 2012 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> Opt("MustDeclareVars", 1) Global $hGUI, $hGraphics, $hBitmapBG, $hBitmap, $hIA, $iWidth, $iHeight, $aRemapTable _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromFile("Untitled2.png") $hBitmapBG = _GDIPlus_BitmapCreateFromFile("Untitled1.png") $iWidth = _GDIPlus_ImageGetWidth($hBitmap) $iHeight = _GDIPlus_ImageGetHeight($hBitmap) $hIA = DllCall($ghGDIPDll, "uint", "GdipCreateImageAttributes", "int*", 0) $hIA = $hIA[1] $aRemapTable[3][2] $aRemapTable[0][0] = 2 $aRemapTable[1][0] = 0xFFED1C24 $aRemapTable[1][1] = 0x00000000 $aRemapTable[2][0] = 0xFF22B14C $aRemapTable[2][1] = 0x00000000 _GDIPlus_ImageAttributesSetRemapTable($hIA, 1, True, $aRemapTable) $hGUI = GUICreate("", $iWidth, $iHeight * 2) GUISetState() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmapBG, 0, 0, _GDIPlus_ImageGetWidth($hBitmapBG), _GDIPlus_ImageGetHeight($hBitmapBG)) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight) _GDIPlus_GraphicsDrawImageRectRectIA($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, $iHeight, $iWidth, $iHeight, $hIA) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE DllCall($ghGDIPDll, "uint", "GdipDisposeImageAttributes", "handle", $hIA) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBitmapBG) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete() Exit Func _GDIPlus_GraphicsDrawImageRectRectIA($hGraphics, $hImage, $nSrcX, $nSrcY, $nSrcWidth, $nSrcHeight, $nDstX, $nDstY, $nDstWidth, $nDstHeight, $hImageAttributes = 0, $iUnit = 2) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectRect", "handle", $hGraphics, "handle", $hImage, "float", $nDstX, "float", _ $nDstY, "float", $nDstWidth, "float", $nDstHeight, "float", $nSrcX, "float", $nSrcY, "float", $nSrcWidth, "float", _ $nSrcHeight, "int", $iUnit, "handle", $hImageAttributes, "int", 0, "int", 0) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] = 0 EndFunc ;==>_GDIPlus_GraphicsDrawImageRectRectIA Func _GDIPlus_ImageAttributesSetRemapTable($hImageAttributes, $iColorAdjustType = 0, $fEnable = False, $aColorMap = 0) Local $iI, $iCount, $tColorMap, $pColorMap, $aResult If IsArray($aColorMap) Then $iCount = $aColorMap[0][0] $tColorMap = DllStructCreate("uint[" & $iCount * 2 & "]") $pColorMap = DllStructGetPtr($tColorMap) For $iI = 1 To $iCount DllStructSetData($tColorMap, 1, $aColorMap[$iI][0], ($iI - 1) * 2 + 1) DllStructSetData($tColorMap, 1, $aColorMap[$iI][1], ($iI - 1) * 2 + 2) Next $aResult = DllCall($ghGDIPDll, "uint", "GdipSetImageAttributesRemapTable", "handle", $hImageAttributes, "int", $iColorAdjustType, "int", $fEnable, "int", $iCount, "ptr", $pColorMap) Else $aResult = DllCall($ghGDIPDll, "uint", "GdipSetImageAttributesRemapTable", "handle", $hImageAttributes, "int", $iColorAdjustType, "int", $fEnable, "int", 0, "ptr", 0) EndIf If @error Then Return SetError(@error, @extended, False) Return $aResult[0] = 0 EndFunc ;==>_GDIPlus_ImageAttributesSetRemapTable Unfortunately it merges only the 2 picture rather than fill it properly. Br, UEZ Edited December 7, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
wolf9228 Posted December 6, 2012 Author Posted December 6, 2012 Nice approach but it can be done also with pure GDI+ only: expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> Opt("MustDeclareVars", 1) Global $hGUI, $hGraphics, $hBitmapBG, $hBitmap, $hIA, $iWidth, $iHeight _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromFile("Untitled2.png") $hBitmapBG = _GDIPlus_BitmapCreateFromFile("Untitled1.png") $iWidth = _GDIPlus_ImageGetWidth($hBitmap) $iHeight = _GDIPlus_ImageGetHeight($hBitmap) $hIA = DllCall($ghGDIPDll, "uint", "GdipCreateImageAttributes", "int*", 0) $hIA = $hIA[1] Local $aRemapTable[3][2] $aRemapTable[0][0] = 2 $aRemapTable[1][0] = 0xFFED1C24 $aRemapTable[1][1] = 0x00000000 $aRemapTable[2][0] = 0xFF22B14C $aRemapTable[2][1] = 0x00000000 _GDIPlus_ImageAttributesSetRemapTable($hIA, 1, True, $aRemapTable) $hGUI = GUICreate("", $iWidth, $iHeight * 2) GUISetState() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmapBG, 0, 0, _GDIPlus_ImageGetWidth($hBitmapBG), _GDIPlus_ImageGetHeight($hBitmapBG)) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight) _GDIPlus_GraphicsDrawImageRectRectIA($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, $iHeight, $iWidth, $iHeight, $hIA) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE DllCall($ghGDIPDll, "uint", "GdipDisposeImageAttributes", "handle", $hIA) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBitmapBG) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete() Exit Func _GDIPlus_GraphicsDrawImageRectRectIA($hGraphics, $hImage, $nSrcX, $nSrcY, $nSrcWidth, $nSrcHeight, $nDstX, $nDstY, $nDstWidth, $nDstHeight, $hImageAttributes = 0, $iUnit = 2) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectRect", "handle", $hGraphics, "handle", $hImage, "float", $nDstX, "float", _ $nDstY, "float", $nDstWidth, "float", $nDstHeight, "float", $nSrcX, "float", $nSrcY, "float", $nSrcWidth, "float", _ $nSrcHeight, "int", $iUnit, "handle", $hImageAttributes, "int", 0, "int", 0) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] = 0 EndFunc ;==>_GDIPlus_GraphicsDrawImageRectRectIA Func _GDIPlus_ImageAttributesSetRemapTable($hImageAttributes, $iColorAdjustType = 0, $fEnable = False, $aColorMap = 0) Local $iI, $iCount, $tColorMap, $pColorMap, $aResult If IsArray($aColorMap) Then $iCount = $aColorMap[0][0] $tColorMap = DllStructCreate("uint[" & $iCount * 2 & "]") $pColorMap = DllStructGetPtr($tColorMap) For $iI = 1 To $iCount DllStructSetData($tColorMap, 1, $aColorMap[$iI][0], ($iI - 1) * 2 + 1) DllStructSetData($tColorMap, 1, $aColorMap[$iI][1], ($iI - 1) * 2 + 2) Next $aResult = DllCall($ghGDIPDll, "uint", "GdipSetImageAttributesRemapTable", "handle", $hImageAttributes, "int", $iColorAdjustType, "int", $fEnable, "int", $iCount, "ptr", $pColorMap) Else $aResult = DllCall($ghGDIPDll, "uint", "GdipSetImageAttributesRemapTable", "handle", $hImageAttributes, "int", $iColorAdjustType, "int", $fEnable, "int", 0, "ptr", 0) EndIf If @error Then Return SetError(@error, @extended, False) Return $aResult[0] = 0 EndFunc ;==>_GDIPlus_ImageAttributesSetRemapTable Unfortunately it merges only the 2 picture rather than fill it properly. Br, UEZ Thank you ...Good work صرح السماء كان هنا
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now