#cs ----------------------------------------------------------------------------

	AutoIt Version: 3.3.6.0
	Author:         name22

	Script Funktion:
	Paint nachbau mit GDI+

#ce ----------------------------------------------------------------------------

#include <WindowsConstants.au3>
#include <GUIImageList.au3>
#include <GUIConstantsEx.au3>
#include <GUIToolBar.au3>
#include <GDIPlus.au3>
#include <Color.au3>
#include <Misc.au3>
#include <Array.au3>

Opt("MouseCoordMode", 2)

Global $iWidth, $iHeight, $Count = 0, $CurSel = 0, $Tool_CurSel = "", $iPenWidth = 1, $iColorRGB = "0x000000", $iColorRGBRed = 0, $iColorRGBGreen = 0, $iColorRGBBlue = 0
Global $ToolBar_Open, $ToolBar_Save
Global $aHistory[500]

Global $hWnd = GUICreate("AutoIt - Paint", 300, 20)
$Menu_File = GUICtrlCreateMenu("&Datei")
$Menu_Effects = GUICtrlCreateMenu("&Effekte")
$Menu_Edit = GUICtrlCreateMenu("&Bearbeiten")
$Menu_Tools = GUICtrlCreateMenu("&Werkzeuge")
$Open = GUICtrlCreateMenuItem("&Öffnen", $Menu_File)
$Save = GUICtrlCreateMenuItem("&Speichern", $Menu_File)
$Invert = GUICtrlCreateMenuItem("&Farben invertieren", $Menu_Effects)
$GrayScale = GUICtrlCreateMenuItem("&Graustufen", $Menu_Effects)
$BlackWhite = GUICtrlCreateMenuItem("&Schwarzweiß", $Menu_Effects)
$ColorIt = GUICtrlCreateMenuItem("&Färben", $Menu_Effects)
$Mouse = GUICtrlCreateMenuItem("&Maus", $Menu_Tools)
$Freehand = GUICtrlCreateMenuItem("&Freihand zeichnen", $Menu_Tools)
$Line = GUICtrlCreateMenuItem("&Linien", $Menu_Tools)
$Rect = GUICtrlCreateMenuItem("&Rechteck", $Menu_Tools)
$Circle = GUICtrlCreateMenuItem("&Kreis", $Menu_Tools)
$Fill = GUICtrlCreateMenuItem("&Füllwerkzeug", $Menu_Tools)
$EyeDropper = GUICtrlCreateMenuItem("&Pipette", $Menu_Tools)
$Undo = GUICtrlCreateMenuItem("&Rückgängig", $Menu_Edit)
$Redo = GUICtrlCreateMenuItem("&Wiederholen", $Menu_Edit)
GUISetState()

$hToolWindow = GUICreate("ToolWindow", 251, 201, 192, 124, $WS_CAPTION)
$PenWidth = GUICtrlCreateInput("1", 8, 24, 49, 21)
GUICtrlSetLimit(-1, 2)
$Label1 = GUICtrlCreateLabel("Stiftbreite:", 8, 8, 51, 17)
$Label2 = GUICtrlCreateLabel("Farbe:", 88, 8, 34, 17)
$Label3 = GUICtrlCreateLabel("000000", 88, 24, 45, 17)
$Label4 = GUICtrlCreateLabel("R=0", 88, 48, 35, 17)
$Label5 = GUICtrlCreateLabel("G=0", 88, 64, 35, 17)
$Label6 = GUICtrlCreateLabel("B=0", 88, 80, 35, 17)
$ReColor = GUICtrlCreateButton("Farbe...", 136, 8, 51, 17, $WS_GROUP)
GUISetState()

;~ $hToolBarWindow = GUICreate("Werkzeugleiste", 300, 25, 0, 0, $WS_CAPTION)
;~ $ToolBar = _GUICtrlToolbar_Create($hToolBarWindow)
;~ _ExtractToolBarIcons($ToolBar, @ScriptDir & "\Icons.dll")

;~ _GUICtrlToolbar_AddButton($ToolBar, $ToolBar_Open, 0)
;~ _GUICtrlToolbar_AddButton($ToolBar, $ToolBar_Save, 1)
;~ GUISetState(@SW_SHOW, $hToolBarWindow)

_GDIPlus_Startup()
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
Global $hPen = _GDIPlus_PenCreate()
Global $hBrush = _GDIPlus_BrushCreateSolid()

GUIRegisterMsg($WM_PAINT, "WM_PAINT")

While 1
	$nMsg = GUIGetMsg(1)
	Switch $nMsg[1]
		Case $hWnd
			Switch $nMsg[0]
				Case $GUI_EVENT_CLOSE
					_Exit()
				Case $GUI_EVENT_RESTORE
					WM_PAINT()
				Case $GUI_EVENT_PRIMARYDOWN
					Switch $Tool_CurSel
						Case "Freehand"
							_DrawFreehand()
						Case "Line"
							_DrawLines()
						Case "Rect"
							_DrawRect()
						Case "Circle"
							_DrawCircle()
						Case "Fill"
							_FloodFill()
							$Tool_CurSel = "Mouse"
						Case "EyeDropper"
							$iColorRGB = "0x" & StringTrimLeft(_GDIPlus_BitmapGetPixel($aHistory[$CurSel], MouseGetPos(0), MouseGetPos(1)), 4)
							_UpdateColors()
							$Tool_CurSel = "Mouse"
					EndSwitch
				Case $Open
					_Open()
				Case $Save
					_Save()
				Case $Invert
					_Invert()
				Case $GrayScale
					_GrayScale()
				Case $BlackWhite
					_BlackWhite()
				Case $ColorIt
					_ColorIt()
				Case $Mouse
					$Tool_CurSel = "Mouse"
				Case $Freehand
					$Tool_CurSel = "Freehand"
				Case $Line
					$Tool_CurSel = "Line"
				Case $Rect
					$Tool_CurSel = "Rect"
				Case $Circle
					$Tool_CurSel = "Circle"
				Case $Fill
					$Tool_CurSel = "Fill"
				Case $EyeDropper
					$Tool_CurSel = "EyeDropper"
				Case $Undo
					If $CurSel > 1 Then $CurSel -= 1
					_WinScale($aHistory[$CurSel])
				Case $Redo
					If $CurSel < $Count Then $CurSel += 1
					_WinScale($aHistory[$CurSel])
			EndSwitch
		Case $hToolWindow
			Switch $nMsg[0]
				Case $PenWidth
					$iPenWidth = GUICtrlRead($PenWidth)
					_UpdateColors()
				Case $ReColor
					$iColor = _ChooseColor(2)
					If Not @error Then
						$iColorRGB = $iColor
						_UpdateColors()
					EndIf
			EndSwitch
;~ 		Case $hToolBarWindow
;~ 			If _GUICtrlToolbar_IsButtonPressed($ToolBar, $ToolBar_Open) Then _Open()
;~ 			If _GUICtrlToolbar_IsButtonPressed($ToolBar, $ToolBar_Save) Then _Save()
;~ 			Switch $nMsg[0]
;~ 				Case $GUI_EVENT_CLOSE

;~ 			EndSwitch
	EndSwitch
WEnd

Func _UpdateColors()
	$iColorRGBRed = _ColorGetRed($iColorRGB)
	$iColorRGBGreen = _ColorGetGreen($iColorRGB)
	$iColorRGBBlue = _ColorGetBlue($iColorRGB)
	GUICtrlSetData($Label3, StringTrimLeft($iColorRGB, 2))
	GUICtrlSetData($Label4, "R=" & $iColorRGBRed)
	GUICtrlSetData($Label5, "G=" & $iColorRGBGreen)
	GUICtrlSetData($Label6, "B=" & $iColorRGBBlue)
	_GDIPlus_PenSetColor($hPen, "0xFF" & StringTrimLeft($iColorRGB, 2))
	_GDIPlus_BrushSetSolidColor($hBrush, "0xFF" & StringTrimLeft($iColorRGB, 2))
	_GDIPlus_PenSetWidth($hPen, $iPenWidth)
EndFunc   ;==>_UpdateColors

Func _DrawFreehand()
	If $Count = 0 Then Return
	$Count += 1
	$CurSel += 1
	_ArrayInsert($aHistory, $CurSel, _GDIPlus_BitmapCloneArea($aHistory[$CurSel - 1], 0, 0, $iWidth, $iHeight))
	$hBuffer = _GDIPlus_ImageGetGraphicsContext($aHistory[$CurSel])
	_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)

	$PosOld = MouseGetPos()
	While _IsPressed("01")
		$PosNew = MouseGetPos()
		_GDIPlus_GraphicsDrawLine($hBuffer, $PosOld[0], $PosOld[1], $PosNew[0], $PosNew[1], $hPen)
		WM_PAINT()
		$PosOld = $PosNew
		Sleep(10)
	WEnd
	_GDIPlus_GraphicsDispose($hBuffer)
EndFunc   ;==>_DrawFreehand

Func _DrawLines()
	If $Count = 0 Then Return
	$Count += 1
	$CurSel += 1
	_ArrayInsert($aHistory, $CurSel, _GDIPlus_BitmapCloneArea($aHistory[$CurSel - 1], 0, 0, $iWidth, $iHeight))
	$hBuffer = _GDIPlus_ImageGetGraphicsContext($aHistory[$CurSel])
	_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)

	$PosOld = MouseGetPos()
	While _IsPressed("01")
		_GDIPlus_GraphicsDrawImageRect($hBuffer, $aHistory[$CurSel - 1], 0, 0, $iWidth, $iHeight)
		$PosNew = MouseGetPos()
		_GDIPlus_GraphicsDrawLine($hBuffer, $PosOld[0], $PosOld[1], $PosNew[0], $PosNew[1], $hPen)
		WM_PAINT()
		Sleep(10)
	WEnd
	_GDIPlus_GraphicsDispose($hBuffer)
EndFunc   ;==>_DrawLines

Func _DrawRect()
	If $Count = 0 Then Return
	$Count += 1
	$CurSel += 1
	_ArrayInsert($aHistory, $CurSel, _GDIPlus_BitmapCloneArea($aHistory[$CurSel - 1], 0, 0, $iWidth, $iHeight))
	$hBuffer = _GDIPlus_ImageGetGraphicsContext($aHistory[$CurSel])
	_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
	$PosOld = MouseGetPos()
	$iX1 = $PosOld[0]
	$iY1 = $PosOld[1]
	$iWidth_Rect = 0
	$iHeight_Rect = 0
	While _IsPressed("01")
		_GDIPlus_GraphicsDrawImageRect($hBuffer, $aHistory[$CurSel - 1], 0, 0, $iWidth, $iHeight)
		$PosNew = MouseGetPos()
		$iWidth_Rect = $PosNew[0] * 2 - $PosOld[0] * 2
		$iHeight_Rect = $PosNew[1] * 2 - $PosOld[1] * 2
		If $iWidth_Rect < 0 Then $iWidth_Rect *= -1
		If $iHeight_Rect < 0 Then $iHeight_Rect *= -1
		$iX1 = $PosOld[0] - $iWidth_Rect / 2
		$iY1 = $PosOld[1] - $iHeight_Rect / 2
		If _IsPressed("10") Then $iHeight_Rect = $iWidth_Rect
		If _IsPressed("11") Then
			_GDIPlus_GraphicsFillRect($hBuffer, $iX1, $iY1, $iWidth_Rect, $iHeight_Rect, $hBrush)
		Else
			_GDIPlus_GraphicsDrawRect($hBuffer, $iX1, $iY1, $iWidth_Rect, $iHeight_Rect, $hPen)
		EndIf
		WM_PAINT()
		Sleep(10)
	WEnd
	_GDIPlus_GraphicsDispose($hBuffer)
EndFunc   ;==>_DrawRect

Func _DrawCircle()
	If $Count = 0 Then Return
	$Count += 1
	$CurSel += 1
	_ArrayInsert($aHistory, $CurSel, _GDIPlus_BitmapCloneArea($aHistory[$CurSel - 1], 0, 0, $iWidth, $iHeight))
	$hBuffer = _GDIPlus_ImageGetGraphicsContext($aHistory[$CurSel])
	_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)

	$PosOld = MouseGetPos()
	$iX1 = $PosOld[0]
	$iY1 = $PosOld[1]
	$iWidth_Ellipse = 0
	$iHeight_Ellipse = 0
	While _IsPressed("01")
		_GDIPlus_GraphicsDrawImageRect($hBuffer, $aHistory[$CurSel - 1], 0, 0, $iWidth, $iHeight)
		$PosNew = MouseGetPos()
		$iWidth_Ellipse = $PosOld[0] * 2 - $PosNew[0] * 2
		$iHeight_Ellipse = $PosOld[1] * 2 - $PosNew[1] * 2
		$iX1 = $PosOld[0] - $iWidth_Ellipse / 2
		$iY1 = $PosOld[1] - $iHeight_Ellipse / 2
		If _IsPressed("10") Then $iHeight_Ellipse = $iWidth_Ellipse
		If _IsPressed("11") Then
			_GDIPlus_GraphicsFillEllipse($hBuffer, $iX1, $iY1, $iWidth_Ellipse, $iHeight_Ellipse, $hBrush)
		Else
			_GDIPlus_GraphicsDrawEllipse($hBuffer, $iX1, $iY1, $iWidth_Ellipse, $iHeight_Ellipse, $hPen)
		EndIf
		WM_PAINT()
		Sleep(10)
	WEnd
	_GDIPlus_GraphicsDispose($hBuffer)
EndFunc   ;==>_DrawCircle

Func _FloodFill()
	If $Count = 0 Then Return
	$Count += 1
	$CurSel += 1
	_ArrayInsert($aHistory, $CurSel, _GDIPlus_BitmapCloneArea($aHistory[$CurSel - 1], 0, 0, $iWidth, $iHeight))

	$ColorTolerance = InputBox("Toleranz", "Bitte den Toleranzwert festlegen 0-255: ", 30)
	If $ColorTolerance = 0 Then Return
	$ToleranceType = InputBox("Toleranz", "Bitte den Toleranztyp auswählen (1=Farbton; 2=Helligkeit): ", 1)
	If $ToleranceType = 0 Then Return

	Do
		Sleep(20)
	Until _IsPressed("01")

	$PosNew = MouseGetPos()
	$PixelColor = _GDIPlus_BitmapGetPixel($aHistory[$CurSel], $PosNew[0], $PosNew[1])
	$PixelColorRed = _ColorGetRed($PixelColor)
	$PixelColorGreen = _ColorGetGreen($PixelColor)
	$PixelColorBlue = _ColorGetBlue($PixelColor)

	$BitmapData = _GDIPlus_BitmapLockBits($aHistory[$CurSel], 0, 0, $iWidth, $iHeight, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32RGB)
	$Scan = DllStructGetData($BitmapData, "Scan0")
	$Stride = DllStructGetData($BitmapData, "Stride")

	ProgressOn("FloodFill", "Fortschritt:", "Pixel werden gescannt...")
	For $iY = 0 To $iHeight - 1
		$PixelData = DllStructCreate("dword[" & $iWidth & ']', $Scan + ($iY * $Stride))
		For $iX = 1 To $iWidth - 1
			$Color = DllStructGetData($PixelData, 1, $iX)
			$ColorRed = _ColorGetRed($Color)
			$ColorGreen = _ColorGetGreen($Color)
			$ColorBlue = _ColorGetBlue($Color)
			Switch $ToleranceType
				Case 1
					If $ColorRed + $ColorTolerance > $PixelColorRed And $ColorGreen + $ColorTolerance > $PixelColorGreen And $ColorBlue - $ColorTolerance < $PixelColorBlue Then DllStructSetData($PixelData, 1, BitOR($iColorRGBBlue, BitShift($iColorRGBGreen, -8), BitShift($iColorRGBRed, -16)), $iX)
				Case 2
					If ($ColorRed + $ColorGreen + $ColorBlue) / 3 > ($PixelColorRed + $PixelColorGreen + $PixelColorBlue) / 3 - $ColorTolerance And ($ColorRed + $ColorGreen + $ColorBlue) / 3 < ($PixelColorRed + $PixelColorGreen + $PixelColorBlue) / 3 + $ColorTolerance Then DllStructSetData($PixelData, 1, BitOR($iColorRGBBlue, BitShift($iColorRGBGreen, -8), BitShift($iColorRGBRed, -16))$iX)
			EndSwitch
		Next
		ProgressSet($iY * 100 / ($iHeight - 1))
	Next
	ProgressOff()
	_GDIPlus_BitmapUnlockBits($aHistory[$CurSel], $BitmapData)
	WM_PAINT()
EndFunc   ;==>_FloodFill

Func _Invert()
	If $Count = 0 Then Return
	$Count += 1
	$CurSel += 1
	_ArrayInsert($aHistory, $CurSel, _GDIPlus_BitmapCloneArea($aHistory[$CurSel - 1], 0, 0, $iWidth, $iHeight))
	$BitmapData = _GDIPlus_BitmapLockBits($aHistory[$CurSel], 0, 0, $iWidth, $iHeight, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB)
	$Scan = DllStructGetData($BitmapData, "Scan0")
	$Stride = DllStructGetData($BitmapData, "Stride")

	ProgressOn("GrayScale", "Fortschritt:", "Pixel werden gescannt...")
	For $iY = 0 To $iHeight - 1
		$PixelData = DllStructCreate("dword[" & $iWidth & ']', $Scan + ($iY * $Stride)) ; Eine Zeile als Struct
		For $iX = 1 To $iWidth
			$Color = DllStructGetData($PixelData, 1, $iX)
			DllStructSetData($PixelData, 1, BitOR(BitAND($Color, 0xFF000000), BitAND(BitNOT($Color), 0x00FFFFFF)), $iX) ; Alpha behalten, Farben komplett invertieren
		Next
		ProgressSet($iY * 100 / ($iHeight - 1))
	Next
	ProgressOff()
	_GDIPlus_BitmapUnlockBits($aHistory[$CurSel], $BitmapData)
	WM_PAINT()
EndFunc   ;==>_Invert

Func _GrayScale()
	If $Count = 0 Then Return
	$Count += 1
	$CurSel += 1
	_ArrayInsert($aHistory, $CurSel, _GDIPlus_BitmapCloneArea($aHistory[$CurSel - 1], 0, 0, $iWidth, $iHeight))
	$BitmapData = _GDIPlus_BitmapLockBits($aHistory[$CurSel], 0, 0, $iWidth, $iHeight, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32RGB)
	$Scan = DllStructGetData($BitmapData, "Scan0")
	$Stride = DllStructGetData($BitmapData, "Stride")

	ProgressOn("GrayScale", "Fortschritt:", "Pixel werden gescannt...")
	For $iY = 0 To $iHeight - 1
		$PixelData = DllStructCreate("dword[" & $iWidth & ']', $Scan + ($iY * $Stride))
		For $iX = 1 To $iWidth - 1
			$Color = DllStructGetData($PixelData, 1, $iX)
			$Color = _ColorGetRed($Color) * 0.3 + _ColorGetGreen($Color) * 0.59 + _ColorGetBlue($Color) * 0.11
			DllStructSetData($PixelData, 1, BitOR($Color, BitShift($Color, -8), BitShift($Color, -16)), $iX)
		Next
		ProgressSet($iY * 100 / ($iHeight - 1))
	Next
	ProgressOff()
	_GDIPlus_BitmapUnlockBits($aHistory[$CurSel], $BitmapData)
	WM_PAINT()
EndFunc   ;==>_GrayScale

Func _BlackWhite()
	If $Count = 0 Then Return
	$Count += 1
	$CurSel += 1
	_ArrayInsert($aHistory, $CurSel, _GDIPlus_BitmapCloneArea($aHistory[$CurSel - 1], 0, 0, $iWidth, $iHeight))
	$Max = InputBox("GrayScale", "Schwellenwert von 0-255: ", 100)
	$BitmapData = _GDIPlus_BitmapLockBits($aHistory[$CurSel], 0, 0, $iWidth, $iHeight, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32RGB)
	$Scan = DllStructGetData($BitmapData, "Scan0")
	$Stride = DllStructGetData($BitmapData, "Stride")

	ProgressOn("BlackWhite", "Fortschritt:", "Pixel werden gescannt...")
	For $iY = 0 To $iHeight - 1
		$PixelData = DllStructCreate("dword[" & $iWidth & ']', $Scan + ($iY * $Stride))
		For $iX = 1 To $iWidth - 1
			$Color = DllStructGetData($PixelData, 1, $iX)
			$Color = _ColorGetRed($Color) + _ColorGetGreen($Color) + _ColorGetBlue($Color) / 3
			If $Color >= $Max Then
				$Color = 0xFFFFFF
			Else
				$Color = 0x000000
			EndIf
			DllStructSetData($PixelData, 1, BitOR($Color, BitShift($Color, -8), BitShift($Color, -16)), $iX)
		Next
		ProgressSet($iY * 100 / ($iHeight - 1))
	Next
	ProgressOff()
	_GDIPlus_BitmapUnlockBits($aHistory[$CurSel], $BitmapData)
	WM_PAINT()
EndFunc   ;==>_BlackWhite

Func _ColorIt()
	If $Count = 0 Then Return
	$Count += 1
	$CurSel += 1
	_ArrayInsert($aHistory, $CurSel, _GDIPlus_BitmapCloneArea($aHistory[$CurSel - 1], 0, 0, $iWidth, $iHeight))
	$hBuffer = _GDIPlus_ImageGetGraphicsContext($aHistory[$CurSel])
	$Color = "0x" & Hex(InputBox("Intensität", "Intensität des Farbfilters von 0-255: ", 50), 2) & StringTrimLeft($iColorRGB, 2)
	If @error Then Return
	$hBrush1 = _GDIPlus_BrushCreateSolid($Color)
	_GDIPlus_GraphicsFillRect($hBuffer, 0, 0, $iWidth, $iHeight, $hBrush)
	_GDIPlus_BrushDispose($hBrush1)
	_GDIPlus_GraphicsDispose($hBuffer)
	WM_PAINT()
EndFunc   ;==>_ColorIt

Func _Open()
	$sFilePath = FileOpenDialog("Datei auswählen", @ScriptDir, "Bilder (*.jpg;*.jpeg;*.png;*.bmp;*.gif)", 3)
	If @error Or $sFilePath = "" Then Return
	$Count += 1
	$CurSel += 1
	_ArrayInsert($aHistory, $CurSel, _GDIPlus_BitmapCreateFromFile($sFilePath))
	_WinScale($aHistory[$CurSel])
EndFunc   ;==>_Open

Func _Save()
	If $Count = 0 Then Return
	$sFileDest = FileSaveDialog("Speichern unter", @ScriptDir, "Bilder (*.jpg;*.jpeg;*.png;*.bmp;*.gif)", 18)
	If @error Or $sFileDest = "" Then Return
	$sExt = StringTrimLeft($sFileDest, StringInStr($sFileDest, ".", 0, -1))
	If Not ($sExt = "jpg" Or $sExt = "jpeg" Or $sExt = "png" Or $sExt = "bmp" Or $sExt = "gif" Or $sExt = "jpg\" Or $sExt = "jpeg\" Or $sExt = "png\" Or $sExt = "bmp\" Or $sExt = "gif\") Then Return MsgBox(16, "Fehler", "Bitte gültige Dateiendung angeben")
	_GDIPlus_ImageSaveToFile($aHistory[$CurSel], $sFileDest)
EndFunc   ;==>_Save

Func _Exit()
	For $i = 0 To $Count
		_GDIPlus_BitmapDispose($aHistory[$i])
	Next
	_GDIPlus_GraphicsDispose($hGraphic)
	_GDIPlus_PenDispose($hPen)
	_GDIPlus_BrushDispose($hBrush)
	_GDIPlus_Shutdown()
	Exit
EndFunc   ;==>_Exit

Func _WinScale($hBitmap)
	If $Count = 0 Then Return
	$iWidth = _GDIPlus_ImageGetWidth($hBitmap)
	$iHeight = _GDIPlus_ImageGetHeight($hBitmap)
	$Pos = WinGetPos($hWnd)
	WinMove($hWnd, "", $Pos[0], $Pos[1], $iWidth + 7, $iHeight + 46)
	_GDIPlus_GraphicsDispose($hGraphic)
	$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
	WM_PAINT()
EndFunc   ;==>_WinScale

Func _GDIPlus_BitmapGetPixel($hBitmapRGB, $iX, $iY)
	; Prog@ndy
	Local $aResult = DllCall($ghGDIPDLL, "int", "GdipBitmapGetPixel", "ptr", $hBitmapRGB, "int", $iX, "int", $iY, "dword*", 0)
	If @error Then Return SetError(1, 0, 0)
	Return SetError($aResult[0], 1, "0x" & Hex($aResult[4]))
EndFunc   ;==>_GDIPlus_BitmapGetPixel

Func WM_PAINT()
	_GDIPlus_GraphicsDrawImageRect($hGraphic, $aHistory[$CurSel], 0, 0, $iWidth, $iHeight)
EndFunc   ;==>WM_PAINT

Func _ExtractToolBarIcons($hWnd_ToolBar, $hLibary)
	$hImage = _GUIImageList_Create()
	$iCount = _WinAPI_ExtractIconEx($hLibary, -1, 0, 0, 0)

	For $i = 0 To $iCount - 1
		_GUIImageList_AddIcon($hImage, $hLibary, $i)
	Next

	_GUICtrlToolbar_SetImageList($hWnd_ToolBar, $hImage)
	Return $iCount
EndFunc   ;==>_ExtractToolBarIcons
