Erstmal ein dickes Hallo an alle.
Ich wende mich nun an euch, weil ich irgendwie ziemlich auf dem Schlauch stehe, und zwar mit allen vieren.
Habe erfolgreich einen Brush mit einem Bild gefüllt, schaffe es aber nicht, dem Brush eine Ellipsen- bzw. Kreisform zu verpassen.
Was mache ich falsch?
AutoIt
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <GDIP.au3>
#include <Misc.au3>
Opt('MouseCoordMode', 2)
Global $dll = DllOpen('user32.dll')
Global $msg
Global $img
Global $width = 600, $height = 600
Global $hWnd = GUICreate("", 600, 647)
Global $brush = GUICtrlCreateButton("Brush", 100, 616, 57, 25, $WS_GROUP)
Global $pen = GUICtrlCreateButton("Pen", 200, 616, 65, 25, $WS_GROUP)
Global $quit = GUICtrlCreateButton("Beenden", 500, 616, 57, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
_GDIPlus_Startup()
Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphics)
Global $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Global $hPen = _GDIPlus_PenCreate(0xFFFFFFF, 3)
AdlibRegister("_newCoords", 10)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
_Exit()
Case $quit
_Exit()
Case $brush
_SetBrush()
Case $pen
;_SetPen()
EndSwitch
WEnd
Func _SetBrush()
Local $img1 = FileOpenDialog("Bild auswählen", "", "Bilder (*.jpg;*.png;*.bmp;*.tif)")
$img = _GDIPlus_ImageLoadFromFile($img1)
Local $iX = _GDIPlus_ImageGetWidth ($img)
Local $iY = _GDIPlus_ImageGetHeight ($img)
Local $hBrush = _GDIPlus_TextureCreate2($img, 0, 0, $iX, $iY, 0)
Local $hContext = _GDIPlus_ImageGetGraphicsContext($img)
_GDIPlus_GraphicsFillEllipse($hContext, 0, 0, $iX, $iY, $hBrush)
_GDIPlus_BrushDispose($hBrush)
EndFunc
Func _newCoords()
Local $mpos = GUIGetCursorInfo()
If IsArray($mpos) Then
If $mpos[2] = 1 Then
Sleep(50)
_GDIPlus_GraphicsDrawImageRect($hBackbuffer, $img, $mpos[0], $mpos[1], 50, 50)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $width, $height)
EndIf
EndIf
EndFunc
Func _Exit()
AdlibUnRegister("_newCoords")
_GDIPlus_PenDispose($hPen)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_ImageDispose($hBackbuffer)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_ImageDispose($img)
_GDIPlus_Shutdown()
Exit
EndFunc
Alles anzeigen