Malkey Posted July 10, 2008 Posted July 10, 2008 (edited) From the example, you can see the center color is set and blends with the surround colors which are white, zero.This is the problem I need help with. The problem being, the surround colors should not all be white. They should be the different colors that are in the array of colors, $aColors[].My thoughts on the problem is, the array of the surround colors is in the wrong format. So the "GdipSetPathGradientSurroundColorsWithCount" wrapper will not accept the surround colors, This function/wrapper accepts the number of colors but not the color values. This line of thinking may also be my problem.Guessing has not helped. I have not been able to find the format output of the "Color colors[] = {Color(255, 0, 0, 0), .... " statement in the example at http://msdn.microsoft.com/en-us/library/ms533917(VS.85).aspxWhat I thought was the output didn't work.Any help or direction would be much appreciated. expandcollapse popup#include <GDIPlus.au3> #include <WinAPI.au3> #include <GuiConstants.au3> ;#include <WindowsConstants.au3> ; The following example creates a GraphicsPath object path, adds an arc to path, closes the arc, and then draws path. ; Creating a Path Gradient @ http://msdn.microsoft.com/en-us/library/ms533917(VS.85).aspx Global $aPoints[11][2] = [[10, 0],[75, 0],[100, 50],[150, 50],[112, 75],[150, 150],[75, 100],[0, 150],[37, 75],[0, 50],[50, 50]] ;Opt("GUIOnEventMode", 1) ;GUISetOnEvent(-3, "close") Global Const $iOpacity = 255 Local $hPath Global $GuiSizeX = 400, $GuiSizeY = 400 $hGui = GUICreate("Paths", $GuiSizeX, $GuiSizeY) GUISetState() _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui) ConsoleWrite("$hGraphic " & Hex($hGraphic) & @CRLF) ;======== CreatePath ===== ; $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", $FillModeAlternate, "ptr", $pPath) ; $FillModeAlternate = 0 ; $FillModeWinding = 1 $hPath = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", 0, "int*", 0) Local $res = "GdipCreatePath " & Hex($hPath[2]) & @CRLF For $x = 0 To 2 $res &= $x & " " & $hPath[$x] & @CRLF Next ConsoleWrite($res & @CRLF) ;======> End of CreatePath === #cs ;======= AddPathArc ========= ;$aResult = DllCall($ghGDIPDll, "int", "GdipAddPathArc", "int", $iX, "int", $iY, "int", $iWidth, "int", $iHeight, "int", $iStartAng, "int", $iSweepAng) $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathArc", "hwnd", $hPath[2], "int", _WinAPI_FloatToInt(150), _ "int", _WinAPI_FloatToInt(150), "int", _WinAPI_FloatToInt(100), "int", _WinAPI_FloatToInt(100), _ "int", _WinAPI_FloatToInt(10), "int", _WinAPI_FloatToInt(180)) $res = "GdipAddPathArc " & @CRLF for $x = 0 to 7 $res &= $x & " " & $aResult[$x] & @CRLF Next ConsoleWrite($res & @CRLF) ;=======> End of AddPathArc ========= #ce _GDIPlus_AddPathLine2($hPath, $aPoints) ;GdipCreatePathGradientFromPath(GDIPCONST GpPath* path, GpPathGradient **polyGradient) $hBrushGrad = DllCall($ghGDIPDll, "int", "GdipCreatePathGradientFromPath", "hwnd", $hPath[2], "int*", 0) ;$hBrushGrad = _GDIPlus_BrushCreateSolid(0xFFFF0000) GDIPlus_SetPathGradientCenterColor($hBrushGrad[2], 0xFFFF0000) ;==== Trying to set Array of colors for SetPathGradientSurroundColorsWithCount ;Global $aColors[10] = ["0xFF00FFFF", "0xFF00FF00", "0xFF0000FF", "0xFFFFFFFF", "0xFF000000", "0xFF00FF00", "0xFF0000FF", "0xFFFFFFFF", "0xFF000000", "0xFF00FF00"] ;Global $aColors[10] = ["FF00FFFF", "FF00FF00", "FF0000FF", "FFFFFFFF", "FF000000", "FF00FF00", "FF0000FF", "FFFFFFFF", "FF000000", "FF00FF00"] Global $aColors[10] = ['FF00FFFF', 'FF00FF00', 'FF0000FF', 'FFFFFFFF', 'FF000000', 'FF00FF00', 'FF0000FF', 'FFFFFFFF', 'FF000000', 'FF00FF00'] ;Global $aColors[10] = [0xFF00FFFF, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00] ;Global $aColors[10] = [_WinAPI_IntToFloat(Dec("FF00FFFF")), _WinAPI_IntToFloat(Dec("FF00FF00")), _WinAPI_IntToFloat(Dec("FF0000FF")), _WinAPI_IntToFloat(Dec("FFFFFFFF")), _WinAPI_IntToFloat(Dec("FF000000")), _WinAPI_IntToFloat(Dec("FF00FF00")), _WinAPI_IntToFloat(Dec("FF0000FF")), _WinAPI_IntToFloat(Dec("FFFFFFFF")), _WinAPI_IntToFloat(Dec("FF000000")), _WinAPI_IntToFloat(Dec("FF00FF00"))] ;Global $aColors[10] = [_WinAPI_FloatToInt(dec("FF00FFFF")), _WinAPI_FloatToInt(dec("FF00FF00")), _WinAPI_FloatToInt(dec("FF0000FF")), _WinAPI_FloatToInt(dec("FFFFFFFF")), _WinAPI_FloatToInt(dec("FF000000")), _WinAPI_FloatToInt(dec("FF00FF00")), _WinAPI_FloatToInt(dec("FF0000FF")), _WinAPI_FloatToInt(dec("FFFFFFFF")), _WinAPI_FloatToInt(dec("FF000000")), _WinAPI_FloatToInt(dec("FF00FF00"))] ;Global $aColors[10] = [dec("FF00FFFF"), dec("FF00FF00"), dec("FF0000FF"), dec("FFFFFFFF"), dec("FF000000"), dec("FF00FF00"), dec("FF0000FF"), dec("FFFFFFFF"), dec("FF000000"), dec("FF00FF00")] ;Global $aColors[1] = [_WinAPI_FloatToInt(0xFFFF00FF)] ; [(Dec (Hex(0, 2) & Hex(255, 2) & Hex(0, 2)))] ;[Dec (0xFF & Hex(0, 2) & Hex(255, 2) & Hex(0, 2))] ;Global $aColors[10] = [0xFF00FFFF, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00] $status = GDIPlus_SetPathGradientSurroundColorsWithCount($hBrushGrad[2], $aColors) ;====> End of Trying to set Array of colors for SetPathGradientSurroundColorsWithCount $aArr = GDIPlus_GetPathGradientSurroundColorsWithCount($hBrushGrad[2]) $aResult1 = DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "hwnd", $hPath[2]) $hPen = _GDIPlus_PenCreate(0xFF000000, 4) ConsoleWrite("$hPen " & Hex($hPen) & @CRLF) _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF) ;_GDIPlus_GraphicsDrawLine ($hGraphic, 10, 150, 390, 150, $hPen) ;========= DrawPath ========= $aResult2 = DllCall($ghGDIPDll, "int", "GdipDrawPath", "hwnd", $hGraphic, "hwnd", $hPen, "hwnd", $hPath[2]) $res = "GdipDrawPath" & @CRLF For $x = 0 To 3 $res &= $x & " " & $aResult2[$x] & @CRLF Next ConsoleWrite($res & @CRLF) ;=========> End of DrawPath ========= ;======= Fill Path - Color path object == ;GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *path) DllCall($ghGDIPDll, "int", "GdipFillPath", "hwnd", $hGraphic, "hwnd", $hBrushGrad[2], "hwnd", $hPath[2]) ;=======> End of Fill Path ============== _GDIPlus_BrushDispose($hBrushGrad) _GDIPlus_PenDispose($hPen) DllCall($ghGDIPDll, "int", "GdipDeletePath", "hwnd", $hPath) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Do Sleep(25) Until GUIGetMsg() = $GUI_EVENT_CLOSE Func close() Exit EndFunc ;==>close ;GdipAddPathPolygon(GpPath *path, GDIPCONST GpPointF *points, INT count) Func _GDIPlus_AddPathPolygon($hPath, $aPoints) Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError $iCount = $aPoints[0][0] $tPoints = DllStructCreate("int[" & $iCount * 2 & "]") $pPoints = DllStructGetPtr($tPoints) For $iI = 1 To $iCount DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][0]), (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][1]), (($iI - 1) * 2) + 2) Next $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathPolygon", "hwnd", $hPath[2], "ptr", _ $pPoints, "int", $iCount) $tmpError = @error $tmpExError = @extended _GDIPlus_BrushDefDispose() If $tmpError Then Return SetError($tmpError, $tmpExError, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_AddPathPolygon ;GpStatus WINGDIPAPI GdipAddPathLine2(GpPath *path, GDIPCONST GpPointF *points, INT count) Func _GDIPlus_AddPathLine2($hPath, $aPoints) Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError $iCount = $aPoints[0][0] $tPoints = DllStructCreate("int[" & $iCount * 2 & "]") $pPoints = DllStructGetPtr($tPoints) For $iI = 1 To $iCount DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][0]), (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][1]), (($iI - 1) * 2) + 2) Next $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathLine2", "hwnd", $hPath[2], "ptr", _ $pPoints, "int", $iCount) $tmpError = @error $tmpExError = @extended _GDIPlus_BrushDefDispose() If $tmpError Then Return SetError($tmpError, $tmpExError, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_AddPathLine2 ;================> GDIPlus_SetPathGradientCenterColor =============== ; Description Sets the center color of this path gradient brush. The center color is the ; color that appears at the brush's center point. ;Parameters ;brush [in] Pointer to the PathGradientBrush object. ;colors [in] An ARGB color that specifies the center color. ;Remarks By default the center point is the centroid of the brush's boundary path, ; but you can set the center point to any location inside or outside the path. ; Func GDIPlus_SetPathGradientCenterColor($hBrush, $iARGB) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientCenterColor", "hwnd", $hBrush, "int", $iARGB) If @error Then Return SetError(@error, @extended, False) Return $aResult ;SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>GDIPlus_SetPathGradientCenterColor ;================================================= ;==============> GDIPlus_SetPathGradientSurroundColorsWithCount =================================== ;Description Sets the surround colors of this path gradient brush. The surround colors are colors ; specified for discrete points on the brush's boundary path. ;Parameters ;brush [in] Pointer to the PathGradientBrush object. ;colors [in] Pointer to an array of ARGB colors that specify the surround colors. ;count [in, out] Pointer to a long integer that, on input, specifies the number of Color objects ; in the colors array. If the method succeeds, this parameter, on output, receives the number ; of surround colors set. If the method fails, this parameter does not receive a value. ;Remarks A path gradient brush has a boundary path and a center point. The center point is set ; to a single color, but you can specify different colors for several points on the boundary. ; For example, suppose you specify red for the center color, and you specify blue, green, ; and yellow for distinct points on the boundary. Then as you move along the boundary, ; the color will change gradually from blue to green to yellow and back to blue. ; As you move along a straight line from any point on the boundary to the center point, ; the color will change from that boundary point's color to red. ; Func GDIPlus_SetPathGradientSurroundColorsWithCount($hBrush, $aArgb) Local $iI, $iCount, $aResult, $res, $x, $pArgb, $tArgb $iCount = UBound($aArgb) ;_WinAPI_FloatToInt(UBound($aArgb)) ; ;$tArgb = DllStructCreate("uint[" & $iCount & "]") ;$pArgb = DllStructGetPtr($tArgb) ;For $iI = 0 To $iCount-1 ; DllStructSetData($tArgb, 1, $aArgb[$iI], $iI+1 ) ;Next $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientSurroundColorsWithCount", "hwnd", $hBrush, "ptr", $pArgb, "int", $iCount) $res = "SetPathGradientSurroundColorsWithCount" & @CRLF For $x = 0 To 3 $res &= $x & " " & $aResult[$x] & @CRLF Next ConsoleWrite($res & @CRLF) If @error Then Return SetError(@error, @extended, 0) Return $aResult ;SetError($aResult[0], 0, $aResult[2]) EndFunc ;==>GDIPlus_SetPathGradientSurroundColorsWithCount ;================================================= ; Gets the number of colors that have been specified for the boundary path of this path gradient brush. Func GDIPlus_GetPathGradientSurroundColorCount($hBrush) Local $iCount, $res, $x ;GdipGetPointCount(GpPath* path, INT* count) $iCount = DllCall($ghGDIPDll, "int", "GdipGetPathGradientSurroundColorCount", "hwnd", $hBrush, "int*", 0) $res = "GdipGetPathGradientSurroundColorCount" & @CRLF For $x = 0 To 2 $res &= $x & " " & $iCount[$x] & @CRLF Next ConsoleWrite($res & @CRLF) Return $iCount[2] EndFunc ;==>GDIPlus_GetPathGradientSurroundColorCount ;GdipGetPathGradientSurroundColorsWithCount( GpPathGradient *brush, ARGB* color, INT* count) Func GDIPlus_GetPathGradientSurroundColorsWithCount($hBrush) Local $iI, $iCount, $aArgb, $tArgb, $pArgb, $aResult, $res $iCount = GDIPlus_GetPathGradientSurroundColorCount($hBrush) Local $aArgb[$iCount] ;$tArgb = DllStructCreate("long[" & $iCount & "]") ;$pArgb = DllStructGetPtr($tArgb) $aResult = DllCall($ghGDIPDll, "int", "GdipGetPathGradientSurroundColorsWithCount", "hwnd", $hBrush, "int", $aArgb, "int", $iCount) $res = "GdipGetPathGradientSurroundColorsWithCount" & @CRLF For $x = 0 To 3 $res &= $x & " " & $aResult[$x] & @CRLF Next ConsoleWrite($res & @CRLF) ;For $iI = 1 To $iCount ; $aArgb[$iI -1] = DllStructGetData($tArgb, 1, $iI ) ;Next $res = "GdipGetPathGradientSurroundColorsWithCount Array Return" & @CRLF For $x = 0 To $iCount - 1 $res &= $x & " " & $aArgb[$x] & @CRLF Next ConsoleWrite($res & @CRLF) If @error Then Return SetError(@error, @extended, 0) Return $aResult ;SetError($aResult[0], 0, $aResult[2]) EndFunc ;==>GDIPlus_GetPathGradientSurroundColorsWithCount ; Return number of points in Path Func GDIPlus_GetPointCount($hPath) Local $iCount, $res, $x ;GdipGetPointCount(GpPath* path, INT* count) $iCount = DllCall($ghGDIPDll, "int", "GdipGetPointCount", "hwnd", $hPath, "int*", 0) $res = "GdipGetPointCount" & @CRLF For $x = 0 To 2 $res &= $x & " " & $iCount[$x] & @CRLF Next ConsoleWrite($res & @CRLF) Return $iCount[2] EndFunc ;==>GDIPlus_GetPointCount ;=================> GDIPlus_SetPathGradientCenterPoint ================================ ;Description Sets the center point of this path gradient brush. By default, ; the center point is at the centroid of the brush's boundary path, but you ; can set the center point to any location inside or outside the path. ;Parameters brush [in] Pointer to the PathGradientBrush object. ; points [out] Pointer to a PointF structure that receives the center point. ;Remarks By default, the center point of a PathGradientBrush object is at the centroid of ; the brush's boundary path, but you can set the center point to any location, inside ; or outside the path, by calling the GdipSetPathGradientCenterPoint function. Func GDIPlus_SetPathGradientCenterPoint($hBrush, $iX, $iY) Local $tPoint, $pPoint, $aResult $tPoint = DllStructCreate("int X;int Y") $pPoint = DllStructGetPtr($tPoint) DllStructSetData($tPoint, "X", _WinAPI_FloatToInt($iX)) DllStructSetData($tPoint, "Y", _WinAPI_FloatToInt($iY)) $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientCenterPoint", "hwnd", $hBrush, "ptr", $pPoint) Return $aResult EndFunc ;==>GDIPlus_SetPathGradientCenterPoint Edited July 12, 2008 by Malkey
Malkey Posted July 12, 2008 Author Posted July 12, 2008 Bump I am still trying to get this to work. Whenever the pointer, $pArgb, is put in this DllCall:- $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientSurroundColorsWithCount", "hwnd", $hBrush, "ptr",$pArgb, "int", $iCount) This error appears:- "autoit3.exe has encountered a problem and needs to close. We are sorry for the inconvenience." If zero or "" or a variable equal to zero or "" replaces $pArgb as the pointer, no error occurrs and no surround colors appear.
ProgAndy Posted July 12, 2008 Posted July 12, 2008 (edited) the fault is one small * If you look at the definition, the count is an int*, nit an int.:GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount( GpPathGradient *brush, GDIPCONST ARGB* color, INT* count)so use th following line and uncomment the DLLStructcreate again !$aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientSurroundColorsWithCount", "hwnd", $hBrush, "ptr",$pArgb, "int*", $iCount)the func: CODEFunc GDIPlus_SetPathGradientSurroundColorsWithCount($hBrush, $aArgb) Local $iI, $iCount, $aResult, $res, $x, $pArgb, $tArgb $iCount = UBound($aArgb) ;_WinAPI_FloatToInt(UBound($aArgb)) ; $tArgb = DllStructCreate("uint[" & $iCount & "]") $pArgb = DllStructGetPtr($tArgb) For $iI = 0 To $iCount-1 DllStructSetData($tArgb, 1, $aArgb[$iI], $iI+1 ) Next $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientSurroundColorsWithCount", "hwnd", $hBrush, "ptr", $pArgb, "int*", $iCount) $res = "SetPathGradientSurroundColorsWithCount" & @CRLF For $x = 0 To 3 $res &= $x & " " & $aResult[$x] & @CRLF Next ConsoleWrite($res & @CRLF) If @error Then Return SetError(@error, @extended, 0) Return $aResult ;SetError($aResult[0], 0, $aResult[2])EndFunc ;==>GDIPlus_SetPathGradientSurroundColorsWithCountWhen you wnat the image to be shoen permanently, you should add WM_APINT and double-buffer e.g.:CODE#include <GDIPlus.au3>#include <WinAPI.au3>#include <GuiConstants.au3>;#include <WindowsConstants.au3>; The following example creates a GraphicsPath object path, adds an arc to path, closes the arc, and then draws path.; Creating a Path Gradient @ http://msdn.microsoft.com/en-us/library/ms533917(VS.85).aspxGlobal $aPoints[11][2] = [[10, 0],[75, 0],[100, 50],[150, 50],[112, 75],[150, 150],[75, 100],[0, 150],[37, 75],[0, 50],[50, 50]];Opt("GUIOnEventMode", 1);GUISetOnEvent(-3, "close")Global Const $iOpacity = 255Local $hPathGlobal $GuiSizeX = 400, $GuiSizeY = 400$hGui = GUICreate("Paths", $GuiSizeX, $GuiSizeY)GUISetState()_GDIPlus_Startup()$hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGui); Create Double Buffer, so the doesn't need to be repainted on PAINT-Event; Just copy the Mem-Imnage to the GUI muttley$hBMPBuff = _GDIPlus_BitmapCreateFromGraphics(400,400,$hGraphicGUI)$hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff);End Double BufferConsoleWrite("$hGraphic " & Hex($hGraphic) & @CRLF);======== CreatePath =====; $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", $FillModeAlternate, "ptr", $pPath); $FillModeAlternate = 0; $FillModeWinding = 1$hPath = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", 0, "int*", 0)Local $res = "GdipCreatePath " & Hex($hPath[2]) & @CRLFFor $x = 0 To 2 $res &= $x & " " & $hPath[$x] & @CRLFNextConsoleWrite($res & @CRLF);======> End of CreatePath ===#cs;======= AddPathArc ========= ;$aResult = DllCall($ghGDIPDll, "int", "GdipAddPathArc", "int", $iX, "int", $iY, "int", $iWidth, "int", $iHeight, "int", $iStartAng, "int", $iSweepAng) $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathArc", "hwnd", $hPath[2], "int", _WinAPI_FloatToInt(150), _ "int", _WinAPI_FloatToInt(150), "int", _WinAPI_FloatToInt(100), "int", _WinAPI_FloatToInt(100), _ "int", _WinAPI_FloatToInt(10), "int", _WinAPI_FloatToInt(180)) $res = "GdipAddPathArc " & @CRLF for $x = 0 to 7 $res &= $x & " " & $aResult[$x] & @CRLF Next ConsoleWrite($res & @CRLF);=======> End of AddPathArc =========#ce_GDIPlus_AddPathLine2($hPath, $aPoints)ConsoleWrite("jjj" & @CRLF);GdipCreatePathGradientFromPath(GDIPCONST GpPath* path, GpPathGradient **polyGradient)$hBrushGrad = DllCall($ghGDIPDll, "int", "GdipCreatePathGradientFromPath", "hwnd", $hPath[2], "int*", 0)ConsoleWrite($hBrushGrad[2] & @CRLF);$hBrushGrad = _GDIPlus_BrushCreateSolid(0xFFFF0000)GDIPlus_SetPathGradientCenterColor($hBrushGrad[2], 0xFFFF0000);==== Trying to set Array of colors for SetPathGradientSurroundColorsWithCount;Global $aColors[10] = ["0xFF00FFFF", "0xFF00FF00", "0xFF0000FF", "0xFFFFFFFF", "0xFF000000", "0xFF00FF00", "0xFF0000FF", "0xFFFFFFFF", "0xFF000000", "0xFF00FF00"];Global $aColors[10] = ["FF00FFFF", "FF00FF00", "FF0000FF", "FFFFFFFF", "FF000000", "FF00FF00", "FF0000FF", "FFFFFFFF", "FF000000", "FF00FF00"]Global $aColors[10] = ['FF00FFFF', 'FF00FF00', 'FF0000FF', 'FFFFFFFF', 'FF000000', 'FF00FF00', 'FF0000FF', 'FFFFFFFF', 'FF000000', 'FF00FF00'];Global $aColors[10] = [0xFF00FFFF, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00];Global $aColors[10] = [_WinAPI_IntToFloat(Dec("FF00FFFF")), _WinAPI_IntToFloat(Dec("FF00FF00")), _WinAPI_IntToFloat(Dec("FF0000FF")), _WinAPI_IntToFloat(Dec("FFFFFFFF")), _WinAPI_IntToFloat(Dec("FF000000")), _WinAPI_IntToFloat(Dec("FF00FF00")), _WinAPI_IntToFloat(Dec("FF0000FF")), _WinAPI_IntToFloat(Dec("FFFFFFFF")), _WinAPI_IntToFloat(Dec("FF000000")), _WinAPI_IntToFloat(Dec("FF00FF00"))];Global $aColors[10] = [_WinAPI_FloatToInt(dec("FF00FFFF")), _WinAPI_FloatToInt(dec("FF00FF00")), _WinAPI_FloatToInt(dec("FF0000FF")), _WinAPI_FloatToInt(dec("FFFFFFFF")), _WinAPI_FloatToInt(dec("FF000000")), _WinAPI_FloatToInt(dec("FF00FF00")), _WinAPI_FloatToInt(dec("FF0000FF")), _WinAPI_FloatToInt(dec("FFFFFFFF")), _WinAPI_FloatToInt(dec("FF000000")), _WinAPI_FloatToInt(dec("FF00FF00"))];Global $aColors[10] = [dec("FF00FFFF"), dec("FF00FF00"), dec("FF0000FF"), dec("FFFFFFFF"), dec("FF000000"), dec("FF00FF00"), dec("FF0000FF"), dec("FFFFFFFF"), dec("FF000000"), dec("FF00FF00")];Global $aColors[1] = [_WinAPI_FloatToInt(0xFFFF00FF)] ; [(Dec (Hex(0, 2) & Hex(255, 2) & Hex(0, 2)))] ;[Dec (0xFF & Hex(0, 2) & Hex(255, 2) & Hex(0, 2))];Global $aColors[10] = [0xFF00FFFF, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00]ConsoleWrite("kl" & @CRLF)$status = GDIPlus_SetPathGradientSurroundColorsWithCount($hBrushGrad[2], $aColors);====> End of Trying to set Array of colors for SetPathGradientSurroundColorsWithCountConsoleWrite("ölö" & @CRLF)$aArr = GDIPlus_GetPathGradientSurroundColorsWithCount($hBrushGrad[2])$aResult1 = DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "hwnd", $hPath[2])$hPen = _GDIPlus_PenCreate(0xFF000000, 4)ConsoleWrite("$hPen " & Hex($hPen) & @CRLF)_GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF);_GDIPlus_GraphicsDrawLine ($hGraphic, 10, 150, 390, 150, $hPen);========= DrawPath =========$aResult2 = DllCall($ghGDIPDll, "int", "GdipDrawPath", "hwnd", $hGraphic, "hwnd", $hPen, "hwnd", $hPath[2])$res = "GdipDrawPath" & @CRLFFor $x = 0 To 3 $res &= $x & " " & $aResult2[$x] & @CRLFNextConsoleWrite($res & @CRLF);=========> End of DrawPath =========;======= Fill Path - Color path object ==;GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *path)DllCall($ghGDIPDll, "int", "GdipFillPath", "hwnd", $hGraphic, "hwnd", $hBrushGrad[2], "hwnd", $hPath[2]);=======> End of Fill Path ==============_GDIPlus_BrushDispose($hBrushGrad)_GDIPlus_PenDispose($hPen)DllCall($ghGDIPDll, "int", "GdipDeletePath", "hwnd", $hPath)GUIRegisterMsg(0xF,"MY_PAINT"); Register PAINT-Event_WinAPI_RedrawWindow($hGui,0,0,2) ;PAINT the windowDo Sleep(25)Until GUIGetMsg() = $GUI_EVENT_CLOSE;Func to redraw the BMP on PAINT MSGFunc MY_PAINT($hWnd, $Msg, $wParam, $lParam) ; Check, if the GUI with the Graphic should be repainted If $hWnd = $hGui Then _GDIPlus_GraphicsDrawImage($hGraphicGUI,$hBMPBuff,0,0)EndFuncFunc close() ExitEndFunc ;==>close;Clean up resources on exitFunc OnAutoItExit() _GDIPlus_GraphicsDispose($hGraphicGUI) _GDIPlus_BitmapDispose($hBMPBuff) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown()EndFunc;GdipAddPathPolygon(GpPath *path, GDIPCONST GpPointF *points, INT count)Func _GDIPlus_AddPathPolygon($hPath, $aPoints) Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError $iCount = $aPoints[0][0] $tPoints = DllStructCreate("int[" & $iCount * 2 & "]") $pPoints = DllStructGetPtr($tPoints) For $iI = 1 To $iCount DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][0]), (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][1]), (($iI - 1) * 2) + 2) Next $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathPolygon", "hwnd", $hPath[2], "ptr", _ $pPoints, "int", $iCount) $tmpError = @error $tmpExError = @extended _GDIPlus_BrushDefDispose() If $tmpError Then Return SetError($tmpError, $tmpExError, False) Return SetError($aResult[0], 0, $aResult[0] = 0)EndFunc ;==>_GDIPlus_AddPathPolygon;GpStatus WINGDIPAPI GdipAddPathLine2(GpPath *path, GDIPCONST GpPointF *points, INT count)Func _GDIPlus_AddPathLine2($hPath, $aPoints) Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError $iCount = $aPoints[0][0] $tPoints = DllStructCreate("int[" & $iCount * 2 & "]") $pPoints = DllStructGetPtr($tPoints) For $iI = 1 To $iCount DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][0]), (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][1]), (($iI - 1) * 2) + 2) Next $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathLine2", "hwnd", $hPath[2], "ptr", _ $pPoints, "int", $iCount) $tmpError = @error $tmpExError = @extended _GDIPlus_BrushDefDispose() If $tmpError Then Return SetError($tmpError, $tmpExError, False) Return SetError($aResult[0], 0, $aResult[0] = 0)EndFunc ;==>_GDIPlus_AddPathLine2;================> GDIPlus_SetPathGradientCenterColor ===============; Description Sets the center color of this path gradient brush. The center color is the; color that appears at the brush's center point.;Parameters;brush [in] Pointer to the PathGradientBrush object.;colors [in] An ARGB color that specifies the center color.;Remarks By default the center point is the centroid of the brush's boundary path,; but you can set the center point to any location inside or outside the path.;Func GDIPlus_SetPathGradientCenterColor($hBrush, $iARGB) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientCenterColor", "hwnd", $hBrush, "int", $iARGB) If @error Then Return SetError(@error, @extended, False) Return $aResult ;SetError($aResult[0], 0, $aResult[0] = 0)EndFunc ;==>GDIPlus_SetPathGradientCenterColor;=================================================;==============> GDIPlus_SetPathGradientSurroundColorsWithCount ===================================;Description Sets the surround colors of this path gradient brush. The surround colors are colors; specified for discrete points on the brush's boundary path.;Parameters;brush [in] Pointer to the PathGradientBrush object.;colors [in] Pointer to an array of ARGB colors that specify the surround colors.;count [in, out] Pointer to a long integer that, on input, specifies the number of Color objects; in the colors array. If the method succeeds, this parameter, on output, receives the number; of surround colors set. If the method fails, this parameter does not receive a value.;Remarks A path gradient brush has a boundary path and a center point. The center point is set; to a single color, but you can specify different colors for several points on the boundary.; For example, suppose you specify red for the center color, and you specify blue, green,; and yellow for distinct points on the boundary. Then as you move along the boundary,; the color will change gradually from blue to green to yellow and back to blue.; As you move along a straight line from any point on the boundary to the center point,; the color will change from that boundary point's color to red.;Func GDIPlus_SetPathGradientSurroundColorsWithCount($hBrush, $aArgb) Local $iI, $iCount, $aResult, $res, $x, $pArgb, $tArgb $iCount = UBound($aArgb) ;_WinAPI_FloatToInt(UBound($aArgb)) ; $tArgb = DllStructCreate("uint[" & $iCount & "]") $pArgb = DllStructGetPtr($tArgb) For $iI = 0 To $iCount-1 DllStructSetData($tArgb, 1, $aArgb[$iI], $iI+1 ) Next $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientSurroundColorsWithCount", "hwnd", $hBrush, "ptr", $pArgb, "int*", $iCount) $res = "SetPathGradientSurroundColorsWithCount" & @CRLF For $x = 0 To 3 $res &= $x & " " & $aResult[$x] & @CRLF Next ConsoleWrite($res & @CRLF) If @error Then Return SetError(@error, @extended, 0) Return $aResult ;SetError($aResult[0], 0, $aResult[2])EndFunc ;==>GDIPlus_SetPathGradientSurroundColorsWithCount;=================================================; Gets the number of colors that have been specified for the boundary path of this path gradient brush.Func GDIPlus_GetPathGradientSurroundColorCount($hBrush) Local $iCount, $res, $x ;GdipGetPointCount(GpPath* path, INT* count) $iCount = DllCall($ghGDIPDll, "int", "GdipGetPathGradientSurroundColorCount", "hwnd", $hBrush, "int*", 0) $res = "GdipGetPathGradientSurroundColorCount" & @CRLF For $x = 0 To 2 $res &= $x & " " & $iCount[$x] & @CRLF Next ConsoleWrite($res & @CRLF) Return $iCount[2]EndFunc ;==>GDIPlus_GetPathGradientSurroundColorCount;GdipGetPathGradientSurroundColorsWithCount( GpPathGradient *brush, ARGB* color, INT* count)Func GDIPlus_GetPathGradientSurroundColorsWithCount($hBrush) Local $iI, $iCount, $aArgb, $tArgb, $pArgb, $aResult, $res $iCount = GDIPlus_GetPathGradientSurroundColorCount($hBrush) Local $aArgb[$iCount] ;$tArgb = DllStructCreate("long[" & $iCount & "]") ;$pArgb = DllStructGetPtr($tArgb) $aResult = DllCall($ghGDIPDll, "int", "GdipGetPathGradientSurroundColorsWithCount", "hwnd", $hBrush, "int", $aArgb, "int", $iCount) $res = "GdipGetPathGradientSurroundColorsWithCount" & @CRLF For $x = 0 To 3 $res &= $x & " " & $aResult[$x] & @CRLF Next ConsoleWrite($res & @CRLF) ;For $iI = 1 To $iCount ; $aArgb[$iI -1] = DllStructGetData($tArgb, 1, $iI ) ;Next $res = "GdipGetPathGradientSurroundColorsWithCount Array Return" & @CRLF For $x = 0 To $iCount - 1 $res &= $x & " " & $aArgb[$x] & @CRLF Next ConsoleWrite($res & @CRLF) If @error Then Return SetError(@error, @extended, 0) Return $aResult ;SetError($aResult[0], 0, $aResult[2])EndFunc ;==>GDIPlus_GetPathGradientSurroundColorsWithCount; Return number of points in PathFunc GDIPlus_GetPointCount($hPath) Local $iCount, $res, $x ;GdipGetPointCount(GpPath* path, INT* count) $iCount = DllCall($ghGDIPDll, "int", "GdipGetPointCount", "hwnd", $hPath, "int*", 0) $res = "GdipGetPointCount" & @CRLF For $x = 0 To 2 $res &= $x & " " & $iCount[$x] & @CRLF Next ConsoleWrite($res & @CRLF) Return $iCount[2]EndFunc ;==>GDIPlus_GetPointCount;=================> GDIPlus_SetPathGradientCenterPoint ================================;Description Sets the center point of this path gradient brush. By default,; the center point is at the centroid of the brush's boundary path, but you; can set the center point to any location inside or outside the path.;Parameters brush [in] Pointer to the PathGradientBrush object.; points [out] Pointer to a PointF structure that receives the center point.;Remarks By default, the center point of a PathGradientBrush object is at the centroid of; the brush's boundary path, but you can set the center point to any location, inside; or outside the path, by calling the GdipSetPathGradientCenterPoint function.Func GDIPlus_SetPathGradientCenterPoint($hBrush, $iX, $iY) Local $tPoint, $pPoint, $aResult $tPoint = DllStructCreate("int X;int Y") $pPoint = DllStructGetPtr($tPoint) DllStructSetData($tPoint, "X", _WinAPI_FloatToInt($iX)) DllStructSetData($tPoint, "Y", _WinAPI_FloatToInt($iY)) $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientCenterPoint", "hwnd", $hBrush, "ptr", $pPoint) Return $aResult EndFunc ;==>GDIPlus_SetPathGradientCenterPoint Edited July 12, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Malkey Posted July 12, 2008 Author Posted July 12, 2008 (edited) Thank-you ProgAndy Very much appreciated. It works expandcollapse popup#include <GDIPlus.au3> #include <WinAPI.au3> #include <GuiConstants.au3> ;#include <WindowsConstants.au3> ; The following example creates a GraphicsPath object path, adds an arc to path, closes the arc, and then draws path. ; Creating a Path Gradient @ http://msdn.microsoft.com/en-us/library/ms533917(VS.85).aspx Global $aPoints[11][2] = [[10, 0],[75, 0],[100, 50],[150, 50],[112, 75],[150, 150],[75, 100],[0, 150],[37, 75],[0, 50],[50, 50]] ;Opt("GUIOnEventMode", 1) ;GUISetOnEvent(-3, "close") Global Const $iOpacity = 255 Local $hPath Global $GuiSizeX = 400, $GuiSizeY = 400 $hGui = GUICreate("Paths", $GuiSizeX, $GuiSizeY) GUISetState() _GDIPlus_Startup() ; Create Double Buffer, so the doesn't need to be repainted on PAINT-Event $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGui) $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics(400, 400, $hGraphicGUI) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff) ;End Double Buffer add-in 1 of 3 ;======== CreatePath ===== ; $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", $FillModeAlternate, "ptr", $pPath) ; $FillModeAlternate = 0 ; $FillModeWinding = 1 $hPath = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", 0, "int*", 0) ;======> End of CreatePath === #cs ;======= AddPathArc ========= ;$aResult = DllCall($ghGDIPDll, "int", "GdipAddPathArc", "int", $iX, "int", $iY, "int", $iWidth, "int", $iHeight, "int", $iStartAng, "int", $iSweepAng) $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathArc", "hwnd", $hPath[2], "int", _WinAPI_FloatToInt(150), _ "int", _WinAPI_FloatToInt(150), "int", _WinAPI_FloatToInt(100), "int", _WinAPI_FloatToInt(100), _ "int", _WinAPI_FloatToInt(10), "int", _WinAPI_FloatToInt(180)) $res = "GdipAddPathArc " & @CRLF for $x = 0 to 7 $res &= $x & " " & $aResult[$x] & @CRLF Next ConsoleWrite($res & @CRLF) ;=======> End of AddPathArc ========= #ce _GDIPlus_AddPathLine2($hPath, $aPoints) ;GdipCreatePathGradientFromPath(GDIPCONST GpPath* path, GpPathGradient **polyGradient) $hBrushGrad = DllCall($ghGDIPDll, "int", "GdipCreatePathGradientFromPath", "hwnd", $hPath[2], "int*", 0) ;$hBrushGrad = _GDIPlus_BrushCreateSolid(0xFFFF0000) GDIPlus_SetPathGradientCenterColor($hBrushGrad[2], 0xFFFF0000) Global $aColors[10] = [0xFF00FFFF, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00] $status = GDIPlus_SetPathGradientSurroundColorsWithCount($hBrushGrad[2], $aColors) $aArr = GDIPlus_GetPathGradientSurroundColorsWithCount($hBrushGrad[2]) $aResult1 = DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "hwnd", $hPath[2]) $hPen = _GDIPlus_PenCreate(0xFF000000, 4) _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF) ;_GDIPlus_GraphicsDrawLine ($hGraphic, 10, 150, 390, 150, $hPen) ;========= DrawPath ========= $aResult2 = DllCall($ghGDIPDll, "int", "GdipDrawPath", "hwnd", $hGraphic, "hwnd", $hPen, "hwnd", $hPath[2]) ;=========> End of DrawPath ========= ;======= Fill Path - Color path object == ;GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *path) DllCall($ghGDIPDll, "int", "GdipFillPath", "hwnd", $hGraphic, "hwnd", $hBrushGrad[2], "hwnd", $hPath[2]) ;=======> End of Fill Path ============== ; Create Double Buffer, so the doesn't need to be repainted on PAINT-Event GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3) _WinAPI_RedrawWindow($hGui, 0, 0, 2) ;PAINT the window Flag $RDW_INTERNALPAINT = 0x0002 ;End Double Buffer add-in 2 of 3 Do Sleep(25) Until GUIGetMsg() = $GUI_EVENT_CLOSE ;Func to redraw the BMP on PAINT MSG Func MY_PAINT($hWnd, $Msg, $wParam, $lParam) ; Check, if the GUI with the Graphic should be repainted If $hWnd = $hGui Then _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) EndFunc ;==>MY_PAINT & End Double Buffer add-in 3 of 3 Func close() _GDIPlus_BrushDispose($hBrushGrad) _GDIPlus_PenDispose($hPen) DllCall($ghGDIPDll, "int", "GdipDeletePath", "hwnd", $hPath) _GDIPlus_GraphicsDispose($hGraphicGUI) _GDIPlus_BitmapDispose($hBMPBuff) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Exit EndFunc ;==>close ;GdipAddPathPolygon(GpPath *path, GDIPCONST GpPointF *points, INT count) Func _GDIPlus_AddPathPolygon($hPath, $aPoints) Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError $iCount = $aPoints[0][0] $tPoints = DllStructCreate("int[" & $iCount * 2 & "]") $pPoints = DllStructGetPtr($tPoints) For $iI = 1 To $iCount DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][0]), (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][1]), (($iI - 1) * 2) + 2) Next $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathPolygon", "hwnd", $hPath[2], "ptr", _ $pPoints, "int", $iCount) $tmpError = @error $tmpExError = @extended _GDIPlus_BrushDefDispose() If $tmpError Then Return SetError($tmpError, $tmpExError, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_AddPathPolygon ;GpStatus WINGDIPAPI GdipAddPathLine2(GpPath *path, GDIPCONST GpPointF *points, INT count) Func _GDIPlus_AddPathLine2($hPath, $aPoints) Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError $iCount = $aPoints[0][0] $tPoints = DllStructCreate("int[" & $iCount * 2 & "]") $pPoints = DllStructGetPtr($tPoints) For $iI = 1 To $iCount DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][0]), (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][1]), (($iI - 1) * 2) + 2) Next $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathLine2", "hwnd", $hPath[2], "ptr", _ $pPoints, "int", $iCount) $tmpError = @error $tmpExError = @extended _GDIPlus_BrushDefDispose() If $tmpError Then Return SetError($tmpError, $tmpExError, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_AddPathLine2 ;================> GDIPlus_SetPathGradientCenterColor =============== ; Description Sets the center color of this path gradient brush. The center color is the ; color that appears at the brush's center point. ;Parameters ;brush [in] Pointer to the PathGradientBrush object. ;colors [in] An ARGB color that specifies the center color. ;Remarks By default the center point is the centroid of the brush's boundary path, ; but you can set the center point to any location inside or outside the path. ; Func GDIPlus_SetPathGradientCenterColor($hBrush, $iARGB) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientCenterColor", "hwnd", $hBrush, "int", $iARGB) If @error Then Return SetError(@error, @extended, False) Return $aResult ;SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>GDIPlus_SetPathGradientCenterColor ;================================================= ;==============> GDIPlus_SetPathGradientSurroundColorsWithCount =================================== ;Description Sets the surround colors of this path gradient brush. The surround colors are colors ; specified for discrete points on the brush's boundary path. ;Parameters ;brush [in] Pointer to the PathGradientBrush object. ;colors [in] Pointer to an array of ARGB colors that specify the surround colors. ;count [in, out] Pointer to a long integer that, on input, specifies the number of Color objects ; in the colors array. If the method succeeds, this parameter, on output, receives the number ; of surround colors set. If the method fails, this parameter does not receive a value. ;Remarks A path gradient brush has a boundary path and a center point. The center point is set ; to a single color, but you can specify different colors for several points on the boundary. ; For example, suppose you specify red for the center color, and you specify blue, green, ; and yellow for distinct points on the boundary. Then as you move along the boundary, ; the color will change gradually from blue to green to yellow and back to blue. ; As you move along a straight line from any point on the boundary to the center point, ; the color will change from that boundary point's color to red. ; Func GDIPlus_SetPathGradientSurroundColorsWithCount($hBrush, $aArgb) Local $iI, $iCount, $aResult, $res, $x, $pArgb, $tArgb $iCount = UBound($aArgb) $tArgb = DllStructCreate("int[" & $iCount & "]") $pArgb = DllStructGetPtr($tArgb) For $iI = 0 To $iCount - 1 DllStructSetData($tArgb, 1, $aArgb[$iI], $iI + 1) Next $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientSurroundColorsWithCount", "hwnd", $hBrush, "ptr", $pArgb, "int*", $iCount) $res = "SetPathGradientSurroundColorsWithCount" & @CRLF For $x = 0 To 3 $res &= $x & " " & $aResult[$x] & @CRLF Next ConsoleWrite($res & @CRLF) If @error Then Return SetError(@error, @extended, 0) Return $aResult ;SetError($aResult[0], 0, $aResult[2]) EndFunc ;==>GDIPlus_SetPathGradientSurroundColorsWithCount ;================================================= ; Gets the number of colors that have been specified for the boundary path of this path gradient brush. Func GDIPlus_GetPathGradientSurroundColorCount($hBrush) Local $iCount, $res, $x ;GdipGetPointCount(GpPath* path, INT* count) $iCount = DllCall($ghGDIPDll, "int", "GdipGetPathGradientSurroundColorCount", "hwnd", $hBrush, "int*", 0) $res = "GdipGetPathGradientSurroundColorCount" & @CRLF For $x = 0 To 2 $res &= $x & " " & $iCount[$x] & @CRLF Next ConsoleWrite($res & @CRLF) Return $iCount[2] EndFunc ;==>GDIPlus_GetPathGradientSurroundColorCount ;GdipGetPathGradientSurroundColorsWithCount( GpPathGradient *brush, ARGB* color, INT* count) Func GDIPlus_GetPathGradientSurroundColorsWithCount($hBrush) Local $iI, $iCount, $aArgb, $tArgb, $pArgb, $aResult, $res $iCount = GDIPlus_GetPathGradientSurroundColorCount($hBrush) Local $aArgb[$iCount] $aResult = DllCall($ghGDIPDll, "int", "GdipGetPathGradientSurroundColorsWithCount", "hwnd", $hBrush, "int", $aArgb, "int*", $iCount) $res = "GdipGetPathGradientSurroundColorsWithCount" & @CRLF For $x = 0 To 3 $res &= $x & " " & $aResult[$x] & @CRLF Next ConsoleWrite($res & @CRLF) $res = "GdipGetPathGradientSurroundColorsWithCount Array Return" & @CRLF For $x = 0 To $iCount - 1 $res &= $x & " " & $aArgb[$x] & @CRLF Next ConsoleWrite($res & @CRLF) If @error Then Return SetError(@error, @extended, 0) Return $aResult ;SetError($aResult[0], 0, $aResult[2]) EndFunc ;==>GDIPlus_GetPathGradientSurroundColorsWithCount ; Return number of points in Path Func GDIPlus_GetPointCount($hPath) Local $iCount, $res, $x ;GdipGetPointCount(GpPath* path, INT* count) $iCount = DllCall($ghGDIPDll, "int", "GdipGetPointCount", "hwnd", $hPath, "int*", 0) $res = "GdipGetPointCount" & @CRLF For $x = 0 To 2 $res &= $x & " " & $iCount[$x] & @CRLF Next ConsoleWrite($res & @CRLF) Return $iCount[2] EndFunc ;==>GDIPlus_GetPointCount ;=================> GDIPlus_SetPathGradientCenterPoint ================================ ;Description Sets the center point of this path gradient brush. By default, ; the center point is at the centroid of the brush's boundary path, but you ; can set the center point to any location inside or outside the path. ;Parameters brush [in] Pointer to the PathGradientBrush object. ; points [out] Pointer to a PointF structure that receives the center point. ;Remarks By default, the center point of a PathGradientBrush object is at the centroid of ; the brush's boundary path, but you can set the center point to any location, inside ; or outside the path, by calling the GdipSetPathGradientCenterPoint function. Func GDIPlus_SetPathGradientCenterPoint($hBrush, $iX, $iY) Local $tPoint, $pPoint, $aResult $tPoint = DllStructCreate("int X;int Y") $pPoint = DllStructGetPtr($tPoint) DllStructSetData($tPoint, "X", _WinAPI_FloatToInt($iX)) DllStructSetData($tPoint, "Y", _WinAPI_FloatToInt($iY)) $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientCenterPoint", "hwnd", $hBrush, "ptr", $pPoint) Return $aResult EndFunc ;==>GDIPlus_SetPathGradientCenterPoint Edit: Reloaded script with Double buffering to redraw on PAINT MSG. It appears to work well. The problem with GDIPlus graphics disappearing seems to be solved. Again, Well done ProgAndy. Edited July 12, 2008 by Malkey
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