Ich hab mich in letzter Zeit mit der objektorientierten Programmierung in AutoIt beschäftigt (AutoItObject), angefangen das Ganze zu verstehen und ich muss sagen ich bin begeistert.
Da ich auch ein GDI+ Fan bin und ich mir dachte, dass GDI+ mit Objekten viel leichter zu handeln wäre, habe ich angefangen das ganze umzusetzen.
Vorweg sage ich gleich dass ich das Skript nur zu Lernzwecken geschrieben habe und deswegen ist ungewiss, ob ich daraus eine komplette UDF machen werde. Aber ich werde mich dennoch bemühen das Skript, soweit wie mir möglich ist, zu erweitern.
Lange Rede, kurzer Sinn, hier die UDF:
Skript
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs Impressum-----------------------------------------------------------------------
AutoIt Version: 3.3.6.1
UDF Version: 0.40.00
Author: Nestos (h2112)
Script Function:
UDF (Funktionssammlung) für die objektorientierte Programmierung mit GDIPlus.
#ce --------------------------------------------------------------------------------
#cs Fortschritte--------------------------------------------------------------------
04.05.2011
Idee für die UDF
Erste Versuche mit OOP in AutoIT
10.05.2011 - 8:55
Erste Funktionen umgesetzt und getestet - erfolgreich:
_OOPGDIP_GraphicsCreate
_OOPGDIP_PenCreate
_OOPGDIP_BrushCreate
_OOPGDIP_LineCreate
_OOPGDIP_FilledEllipseCreate
10.05.2011 - 12:05
Weitere Formen umgesetzt:
_OOPGDIP_FilledPolygonCreate
_OOPGDIP_PolygonCreate
_OOPGDIP_FilledRectCreate
_OOPGDIP_RectCreate
_OOPGDIP_EllipseCreate
10.05.2011 - 15:45
Umgesetzte Methoden:
graphic.dispose
pen.dispose
brush.dispose
Umgesetzte Funktionen:
_OOPGDIP_BufferCreate
11.05.2011 - 16:05
Skript aufgeräumt und in UDF-Form gebracht
Umgesetzte Funktionserweiterungen:
_OOPGDIP_BufferCreate & _OOPGDIP_GraphicsCreate Property clearcolor hinzufügen
Umgesetzte Methoden:
Buffer.update
Umgesetzte Funktionsänderungen:
Formen - update-Methoden zu draw umbenennen
12.05.2011 - 22:00
Alle Standardformen von GDIPlus.au3 umgesetzt:
_OOPGDIP_PieCreate
_OOPGDIP_ClosedCurveCreate
_OOPGDIP_FilledClosedCurveCreate
_OOPGDIP_CurveCreate
_OOPGDIP_BezierCreate
13.05.2011 - 08:35
_OOPGDIP_ImageCreate umgesetzt
31.05.2011 - 08:35
_OOPGDIP_StringCreate umgesetzt
02.06.2011 -
_OOPGDIP_FontCreate umgesetzt
_OOPGDIP_StringExCreate umgesetzt
#ce --------------------------------------------------------------------------------
#cs Funktionen----------------------------------------------------------------------
_OOPGDIP_StartUp
_OOPGDIP_ShutDown
_OOPGDIP_GraphicsCreate
_OOPGDIP_PenCreate
_OOPGDIP_BrushCreate
_OOPGDIP_LineCreate
_OOPGDIP_FilledEllipseCreate
_OOPGDIP_FilledPolygonCreate
_OOPGDIP_PolygonCreate
_OOPGDIP_FilledRectCreate
_OOPGDIP_RectCreate
_OOPGDIP_EllipseCreate
#ce --------------------------------------------------------------------------------
#cs Interne Funktionen--------------------------------------------------------------
__OOPGDIP_FilledEllipsedraw
__OOPGDIP_BrushUpdate
__OOPGDIP_PenUpdate
__OOPGDIP_GraphicsClear
__OOPGDIP_Linedraw
__OOPGDIP_FilledPolygondraw
__OOPGDIP_Polygondraw
__OOPGDIP_FilledRectdraw
__OOPGDIP_Rectdraw
__OOPGDIP_Ellipsedraw
__OOPGDIP_FilledEllipsedraw
#ce --------------------------------------------------------------------------------
#Region Include---------------------------------------------------------------------
#include-once
#include <AutoItObject.au3>
#include <GDIPlus.au3>
#EndRegion Include---------------------------------------------------------------------
;EndRegion Include------------------------------------------------------------------
#Region Variablen-------------------------------------------------------------------
Global $OOPGDIP_Test = False
Global $OOPGDIPStringExStruct[100] = [0]
If $OOPGDIP_Test Then __OOPGDIP_TestRun()
#EndRegion Variablen-------------------------------------------------------------------
;EndRegion Variablen----------------------------------------------------------------
#Region Formen----------------------------------------------------------------------
Func _OOPGDIP_LineCreate($Graphics, $x1Pos, $y1Pos, $x2Pos, $y2Pos, $Pen)
Local $oGDIPLine = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPLine, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPLine, "x1Pos", $ELSCOPE_PUBLIC, $x1Pos)
_AutoItObject_AddProperty($oGDIPLine, "y1Pos", $ELSCOPE_PUBLIC, $y1Pos)
_AutoItObject_AddProperty($oGDIPLine, "x2Pos", $ELSCOPE_PUBLIC, $x2Pos)
_AutoItObject_AddProperty($oGDIPLine, "y2Pos", $ELSCOPE_PUBLIC, $y2Pos)
_AutoItObject_AddProperty($oGDIPLine, "pen", $ELSCOPE_PUBLIC, $Pen.handle)
_AutoItObject_AddMethod($oGDIPLine, "draw", "__OOPGDIP_LineDraw")
Return $oGDIPLine
EndFunc ;==>_OOPGDIP_LineCreate
Func __OOPGDIP_LineDraw($oSelf)
_GDIPlus_GraphicsDrawLine($oSelf.graphic, $oSelf.x1Pos, $oSelf.y1Pos, $oSelf.x2Pos, $oSelf.y2Pos, $oSelf.pen)
EndFunc ;==>__OOPGDIP_LineDraw
Func _OOPGDIP_RectCreate($Graphics, $xPos, $yPos, $width, $height, $Pen)
Local $oGDIPRect = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPRect, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPRect, "xPos", $ELSCOPE_PUBLIC, $xPos)
_AutoItObject_AddProperty($oGDIPRect, "yPos", $ELSCOPE_PUBLIC, $yPos)
_AutoItObject_AddProperty($oGDIPRect, "width", $ELSCOPE_PUBLIC, $width)
_AutoItObject_AddProperty($oGDIPRect, "height", $ELSCOPE_PUBLIC, $height)
_AutoItObject_AddProperty($oGDIPRect, "pen", $ELSCOPE_PUBLIC, $Pen.handle)
_AutoItObject_AddMethod($oGDIPRect, "draw", "__OOPGDIP_RectDraw")
Return $oGDIPRect
EndFunc ;==>_OOPGDIP_RectCreate
Func __OOPGDIP_RectDraw($oSelf)
_GDIPlus_GraphicsDrawRect($oSelf.graphic, $oSelf.xPos, $oSelf.yPos, $oSelf.width, $oSelf.height, $oSelf.pen)
EndFunc ;==>__OOPGDIP_RectDraw
Func _OOPGDIP_FilledRectCreate($Graphics, $xPos, $yPos, $width, $height, $Brush)
Local $oGDIPFilledRect = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPFilledRect, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPFilledRect, "xPos", $ELSCOPE_PUBLIC, $xPos)
_AutoItObject_AddProperty($oGDIPFilledRect, "yPos", $ELSCOPE_PUBLIC, $yPos)
_AutoItObject_AddProperty($oGDIPFilledRect, "width", $ELSCOPE_PUBLIC, $width)
_AutoItObject_AddProperty($oGDIPFilledRect, "height", $ELSCOPE_PUBLIC, $height)
_AutoItObject_AddProperty($oGDIPFilledRect, "brush", $ELSCOPE_PUBLIC, $Brush.handle)
_AutoItObject_AddMethod($oGDIPFilledRect, "draw", "__OOPGDIP_FilledRectDraw")
Return $oGDIPFilledRect
EndFunc ;==>_OOPGDIP_FilledRectCreate
Func __OOPGDIP_FilledRectDraw($oSelf)
_GDIPlus_GraphicsFillRect($oSelf.graphic, $oSelf.xPos, $oSelf.yPos, $oSelf.width, $oSelf.height, $oSelf.brush)
EndFunc ;==>__OOPGDIP_FilledRectDraw
Func _OOPGDIP_PolygonCreate($Graphics, $cords, $Pen)
Local $oGDIPPolygon = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPPolygon, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPPolygon, "cords", $ELSCOPE_PUBLIC, $cords)
_AutoItObject_AddProperty($oGDIPPolygon, "pen", $ELSCOPE_PUBLIC, $Pen.handle)
_AutoItObject_AddMethod($oGDIPPolygon, "draw", "__OOPGDIP_PolygonDraw")
Return $oGDIPPolygon
EndFunc ;==>_OOPGDIP_PolygonCreate
Func __OOPGDIP_PolygonDraw($oSelf)
_GDIPlus_GraphicsDrawPolygon($oSelf.graphic, $oSelf.cords, $oSelf.pen)
EndFunc ;==>__OOPGDIP_PolygonDraw
Func _OOPGDIP_FilledPolygonCreate($Graphics, $cords, $Brush)
Local $oGDIPFilledPolygon = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPFilledPolygon, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPFilledPolygon, "cords", $ELSCOPE_PUBLIC, $cords)
_AutoItObject_AddProperty($oGDIPFilledPolygon, "brush", $ELSCOPE_PUBLIC, $Brush.handle)
_AutoItObject_AddMethod($oGDIPFilledPolygon, "draw", "__OOPGDIP_FilledPolygonDraw")
Return $oGDIPFilledPolygon
EndFunc ;==>_OOPGDIP_FilledPolygonCreate
Func __OOPGDIP_FilledPolygonDraw($oSelf)
_GDIPlus_GraphicsFillPolygon($oSelf.graphic, $oSelf.cords, $oSelf.brush)
EndFunc ;==>__OOPGDIP_FilledPolygonDraw
Func _OOPGDIP_EllipseCreate($Graphics, $xPos, $yPos, $width, $height, $Pen, $StartAngle = 0, $EndAngle = 360)
Local $oGDIPEllipse = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPEllipse, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPEllipse, "xPos", $ELSCOPE_PUBLIC, $xPos)
_AutoItObject_AddProperty($oGDIPEllipse, "yPos", $ELSCOPE_PUBLIC, $yPos)
_AutoItObject_AddProperty($oGDIPEllipse, "width", $ELSCOPE_PUBLIC, $width)
_AutoItObject_AddProperty($oGDIPEllipse, "height", $ELSCOPE_PUBLIC, $height)
_AutoItObject_AddProperty($oGDIPEllipse, "pen", $ELSCOPE_PUBLIC, $Pen.handle)
_AutoItObject_AddProperty($oGDIPEllipse, "sangle", $ELSCOPE_PUBLIC, $StartAngle)
_AutoItObject_AddProperty($oGDIPEllipse, "eangle", $ELSCOPE_PUBLIC, $EndAngle)
_AutoItObject_AddMethod($oGDIPEllipse, "draw", "__OOPGDIP_EllipseDraw")
Return $oGDIPEllipse
EndFunc ;==>_OOPGDIP_EllipseCreate
Func __OOPGDIP_EllipseDraw($oSelf)
_GDIPlus_GraphicsDrawArc($oSelf.graphic, $oSelf.xPos, $oSelf.yPos, $oSelf.width, $oSelf.height, $oSelf.sangle, $oSelf.eangle, $oSelf.pen)
EndFunc ;==>__OOPGDIP_EllipseDraw
Func _OOPGDIP_FilledEllipseCreate($Graphics, $xPos, $yPos, $width, $height, $Brush, $StartAngle = 0, $EndAngle = 360)
Local $oGDIPFilledEllipse = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPFilledEllipse, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPFilledEllipse, "xPos", $ELSCOPE_PUBLIC, $xPos)
_AutoItObject_AddProperty($oGDIPFilledEllipse, "yPos", $ELSCOPE_PUBLIC, $yPos)
_AutoItObject_AddProperty($oGDIPFilledEllipse, "width", $ELSCOPE_PUBLIC, $width)
_AutoItObject_AddProperty($oGDIPFilledEllipse, "height", $ELSCOPE_PUBLIC, $height)
_AutoItObject_AddProperty($oGDIPFilledEllipse, "brush", $ELSCOPE_PUBLIC, $Brush.handle)
_AutoItObject_AddProperty($oGDIPFilledEllipse, "sangle", $ELSCOPE_PUBLIC, $StartAngle)
_AutoItObject_AddProperty($oGDIPFilledEllipse, "eangle", $ELSCOPE_PUBLIC, $EndAngle)
_AutoItObject_AddMethod($oGDIPFilledEllipse, "draw", "__OOPGDIP_FilledEllipseDraw")
Return $oGDIPFilledEllipse
EndFunc ;==>_OOPGDIP_FilledEllipseCreate
Func __OOPGDIP_FilledEllipseDraw($oSelf)
_GDIPlus_GraphicsFillPie($oSelf.graphic, $oSelf.xPos, $oSelf.yPos, $oSelf.width, $oSelf.height, $oSelf.sangle, $oSelf.eangle, $oSelf.brush)
EndFunc ;==>__OOPGDIP_FilledEllipseDraw
Func _OOPGDIP_PieCreate($Graphics, $xPos, $yPos, $width, $height, $Pen, $StartAngle = 0, $EndAngle = 360)
Local $oGDIPPie = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPPie, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPPie, "xPos", $ELSCOPE_PUBLIC, $xPos)
_AutoItObject_AddProperty($oGDIPPie, "yPos", $ELSCOPE_PUBLIC, $yPos)
_AutoItObject_AddProperty($oGDIPPie, "width", $ELSCOPE_PUBLIC, $width)
_AutoItObject_AddProperty($oGDIPPie, "height", $ELSCOPE_PUBLIC, $height)
_AutoItObject_AddProperty($oGDIPPie, "pen", $ELSCOPE_PUBLIC, $Pen.handle)
_AutoItObject_AddProperty($oGDIPPie, "sangle", $ELSCOPE_PUBLIC, $StartAngle)
_AutoItObject_AddProperty($oGDIPPie, "eangle", $ELSCOPE_PUBLIC, $EndAngle)
_AutoItObject_AddMethod($oGDIPPie, "draw", "__OOPGDIP_PieDraw")
Return $oGDIPPie
EndFunc ;==>_OOPGDIP_PieCreate
Func __OOPGDIP_PieDraw($oSelf)
_GDIPlus_GraphicsDrawPie($oSelf.graphic, $oSelf.xPos, $oSelf.yPos, $oSelf.width, $oSelf.height, $oSelf.sangle, $oSelf.eangle, $oSelf.pen)
EndFunc ;==>__OOPGDIP_PieDraw
Func _OOPGDIP_ClosedCurveCreate($Graphics, $cords, $Pen)
Local $oGDIPClosedCurve = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPClosedCurve, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPClosedCurve, "cords", $ELSCOPE_PUBLIC, $cords)
_AutoItObject_AddProperty($oGDIPClosedCurve, "pen", $ELSCOPE_PUBLIC, $Pen.handle)
_AutoItObject_AddMethod($oGDIPClosedCurve, "draw", "__OOPGDIP_ClosedCurveDraw")
Return $oGDIPClosedCurve
EndFunc ;==>_OOPGDIP_ClosedCurveCreate
Func __OOPGDIP_ClosedCurveDraw($oSelf)
_GDIPlus_GraphicsDrawClosedCurve($oSelf.graphic, $oSelf.cords, $oSelf.pen)
EndFunc ;==>__OOPGDIP_ClosedCurveDraw
Func _OOPGDIP_FilledClosedCurveCreate($Graphics, $cords, $Brush)
Local $oGDIPFilledClosedCurve = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPFilledClosedCurve, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPFilledClosedCurve, "cords", $ELSCOPE_PUBLIC, $cords)
_AutoItObject_AddProperty($oGDIPFilledClosedCurve, "brush", $ELSCOPE_PUBLIC, $Brush.handle)
_AutoItObject_AddMethod($oGDIPFilledClosedCurve, "draw", "__OOPGDIP_FilledClosedCurveDraw")
Return $oGDIPFilledClosedCurve
EndFunc ;==>_OOPGDIP_FilledClosedCurveCreate
Func __OOPGDIP_FilledClosedCurveDraw($oSelf)
_GDIPlus_GraphicsFillClosedCurve($oSelf.graphic, $oSelf.cords, $oSelf.brush)
EndFunc ;==>__OOPGDIP_FilledClosedCurveDraw
Func _OOPGDIP_CurveCreate($Graphics, $cords, $Pen)
Local $oGDIPCurve = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPCurve, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPCurve, "cords", $ELSCOPE_PUBLIC, $cords)
_AutoItObject_AddProperty($oGDIPCurve, "pen", $ELSCOPE_PUBLIC, $Pen.handle)
_AutoItObject_AddMethod($oGDIPCurve, "draw", "__OOPGDIP_CurveDraw")
Return $oGDIPCurve
EndFunc ;==>_OOPGDIP_CurveCreate
Func __OOPGDIP_CurveDraw($oSelf)
_GDIPlus_GraphicsDrawCurve($oSelf.graphic, $oSelf.cords, $oSelf.pen)
EndFunc ;==>__OOPGDIP_CurveDraw
Func _OOPGDIP_BezierCreate($Graphics, $x1Pos, $y1Pos, $x2Pos, $y2Pos, $x3Pos, $y3Pos, $x4Pos, $y4Pos, $Pen)
Local $oGDIPBezier = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPBezier, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPBezier, "x1Pos", $ELSCOPE_PUBLIC, $x1Pos)
_AutoItObject_AddProperty($oGDIPBezier, "y1Pos", $ELSCOPE_PUBLIC, $y1Pos)
_AutoItObject_AddProperty($oGDIPBezier, "x2Pos", $ELSCOPE_PUBLIC, $x2Pos)
_AutoItObject_AddProperty($oGDIPBezier, "y2Pos", $ELSCOPE_PUBLIC, $y2Pos)
_AutoItObject_AddProperty($oGDIPBezier, "x3Pos", $ELSCOPE_PUBLIC, $x3Pos)
_AutoItObject_AddProperty($oGDIPBezier, "y3Pos", $ELSCOPE_PUBLIC, $y3Pos)
_AutoItObject_AddProperty($oGDIPBezier, "x4Pos", $ELSCOPE_PUBLIC, $x4Pos)
_AutoItObject_AddProperty($oGDIPBezier, "y4Pos", $ELSCOPE_PUBLIC, $y4Pos)
_AutoItObject_AddProperty($oGDIPBezier, "pen", $ELSCOPE_PUBLIC, $Pen.handle)
_AutoItObject_AddMethod($oGDIPBezier, "draw", "__OOPGDIP_BezierDraw")
Return $oGDIPBezier
EndFunc ;==>_OOPGDIP_BezierCreate
Func __OOPGDIP_BezierDraw($oSelf)
_GDIPlus_GraphicsDrawBezier($oSelf.graphic, $oSelf.x1Pos, $oSelf.y1Pos, $oSelf.x2Pos, $oSelf.y2Pos, $oSelf.x3Pos, $oSelf.y3Pos, $oSelf.x4Pos, $oSelf.y4Pos, $oSelf.pen)
EndFunc ;==>__OOPGDIP_BezierDraw
#EndRegion Formen----------------------------------------------------------------------
;EndRegion Formen-------------------------------------------------------------------
#Region Besondere-Formen------------------------------------------------------------
Func _OOPGDIP_ImageCreate($Graphics, $Image, $x1Pos, $y1Pos, $width1 = Default, $height1 = Default, $x2Pos = 0, $y2Pos = 0, $width2 = Default, $height2 = Default, $unit = 2)
Local $oGDIPImage = _AutoItObject_Create()
Local $aOriginalCords[2] = [_GDIPlus_ImageGetWidth($Image), _GDIPlus_ImageGetHeight($Image)]
If $width1 = Default Then $width1 = $aOriginalCords[0]
If $height1 = Default Then $height1 = $aOriginalCords[1]
If $width2 = Default Then $width2 = $aOriginalCords[0]
If $height2 = Default Then $height2 = $aOriginalCords[1]
_AutoItObject_AddProperty($oGDIPImage, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPImage, "image", $ELSCOPE_PUBLIC, Number($Image))
_AutoItObject_AddProperty($oGDIPImage, "x1Pos", $ELSCOPE_PUBLIC, $x1Pos)
_AutoItObject_AddProperty($oGDIPImage, "y1Pos", $ELSCOPE_PUBLIC, $y1Pos)
_AutoItObject_AddProperty($oGDIPImage, "width1", $ELSCOPE_PUBLIC, $width1)
_AutoItObject_AddProperty($oGDIPImage, "height1", $ELSCOPE_PUBLIC, $height1)
_AutoItObject_AddProperty($oGDIPImage, "x2Pos", $ELSCOPE_PUBLIC, $x2Pos)
_AutoItObject_AddProperty($oGDIPImage, "y2Pos", $ELSCOPE_PUBLIC, $y2Pos)
_AutoItObject_AddProperty($oGDIPImage, "width2", $ELSCOPE_PUBLIC, $width2)
_AutoItObject_AddProperty($oGDIPImage, "height2", $ELSCOPE_PUBLIC, $height2)
_AutoItObject_AddProperty($oGDIPImage, "unit", $ELSCOPE_PUBLIC, $unit)
_AutoItObject_AddMethod($oGDIPImage, "draw", "__OOPGDIP_ImageDraw")
Return $oGDIPImage
EndFunc ;==>_OOPGDIP_ImageCreate
Func __OOPGDIP_ImageDraw($oSelf)
_GDIPlus_GraphicsDrawImageRectRect($oSelf.graphic, $oSelf.image, $oSelf.x2Pos, $oSelf.y2Pos, $oSelf.width2, $oSelf.height2, $oSelf.x1Pos, $oSelf.y1Pos, $oSelf.width1, $oSelf.height1, $oSelf.unit)
EndFunc ;==>__OOPGDIP_ImageDraw
Func _OOPGDIP_StringCreate($Graphics, $Text, $xPos, $yPos, $Font = "Arial", $Size = 10, $Format = 0)
Local $oGDIPString = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPString, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPString, "text", $ELSCOPE_PUBLIC, $Text)
_AutoItObject_AddProperty($oGDIPString, "xPos", $ELSCOPE_PUBLIC, $xPos)
_AutoItObject_AddProperty($oGDIPString, "yPos", $ELSCOPE_PUBLIC, $yPos)
_AutoItObject_AddProperty($oGDIPString, "font", $ELSCOPE_PUBLIC, $Font)
_AutoItObject_AddProperty($oGDIPString, "size", $ELSCOPE_PUBLIC, $Size)
_AutoItObject_AddProperty($oGDIPString, "format", $ELSCOPE_PUBLIC, $Format)
_AutoItObject_AddMethod($oGDIPString, "draw", "__OOPGDIP_StringDraw")
Return $oGDIPString
EndFunc ;==>_OOPGDIP_StringCreate
Func __OOPGDIP_StringDraw($oSelf)
_GDIPlus_GraphicsDrawString($oSelf.graphic, $oSelf.text, $oSelf.xPos, $oSelf.yPos, $oSelf.font, $oSelf.size, $oSelf.format)
EndFunc ;==>__OOPGDIP_StringDraw
Func _OOPGDIP_StringExCreate($Graphics, $Text, $xPos, $yPos, $width, $height, $Font, $Brush = 0)
Local $tLayout = _GDIPlus_RectFCreate($xPos, $yPos, $width, $height)
Local $aInfo = _GDIPlus_GraphicsMeasureString($Graphics.graphic, $Text, $Font.handle, $tLayout, $Font.hformat)
$OOPGDIPStringExStruct[0] += 1
$OOPGDIPStringExStruct[$OOPGDIPStringExStruct[0]] = $aInfo[0]
Local $oGDIPStringEx = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPStringEx, "graphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPStringEx, "brush", $ELSCOPE_PUBLIC, $Brush.handle)
_AutoItObject_AddProperty($oGDIPStringEx, "font", $ELSCOPE_PUBLIC, $Font.handle)
_AutoItObject_AddProperty($oGDIPStringEx, "hformat", $ELSCOPE_PUBLIC, $Font.hformat)
_AutoItObject_AddProperty($oGDIPStringEx, "text", $ELSCOPE_PUBLIC, $Text)
_AutoItObject_AddProperty($oGDIPStringEx, "xPos", $ELSCOPE_PUBLIC, $xPos)
_AutoItObject_AddProperty($oGDIPStringEx, "yPos", $ELSCOPE_PUBLIC, $yPos)
_AutoItObject_AddProperty($oGDIPStringEx, "width", $ELSCOPE_PUBLIC, $width)
_AutoItObject_AddProperty($oGDIPStringEx, "height", $ELSCOPE_PUBLIC, $height)
_AutoItObject_AddProperty($oGDIPStringEx, "struct", $ELSCOPE_PUBLIC, $OOPGDIPStringExStruct[0])
_AutoItObject_AddMethod($oGDIPStringEx, "update", "__OOPGDIP_StringExUpdate")
_AutoItObject_AddMethod($oGDIPStringEx, "draw", "__OOPGDIP_StringExDraw")
Return $oGDIPStringEx
EndFunc ;==>_OOPGDIP_StringExCreate
Func __OOPGDIP_StringExDraw($oSelf)
_GDIPlus_GraphicsDrawStringEx($oSelf.graphic, $oSelf.text, $oSelf.font, $OOPGDIPStringExStruct[$oSelf.struct], $oSelf.hformat, $oSelf.brush)
EndFunc ;==>__OOPGDIP_StringExDraw
Func __OOPGDIP_StringExUpdate($oSelf)
Local $tLayout = _GDIPlus_RectFCreate($oSelf.xPos, $oSelf.yPos, $oSelf.width, $oSelf.height)
Local $aInfo = _GDIPlus_GraphicsMeasureString($oSelf.graphic, $oSelf.text, $oSelf.font, $tLayout, $oSelf.hformat)
$OOPGDIPStringExStruct[$oSelf.struct] = $aInfo[0]
EndFunc ;==>__OOPGDIP_StringExUpdate
#EndRegion Besondere-Formen------------------------------------------------------------
;EndRegion Besondere-Formen---------------------------------------------------------
#Region Graphic---------------------------------------------------------------------
Func _OOPGDIP_GraphicsCreate($hWnd, $clearcolor = 0xFF000000)
Local $GDIPGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
Local $oGDIPGraphic = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPGraphic, "graphic", $ELSCOPE_PUBLIC, Number($GDIPGraphic))
_AutoItObject_AddProperty($oGDIPGraphic, "clearcolor", $ELSCOPE_PUBLIC, $clearcolor)
_AutoItObject_AddMethod($oGDIPGraphic, "clear", "__OOPGDIP_GraphicsClear")
_AutoItObject_AddMethod($oGDIPGraphic, "dispose", "__OOPGDIP_GraphicsDispose")
Return $oGDIPGraphic
EndFunc ;==>_OOPGDIP_GraphicsCreate
Func __OOPGDIP_GraphicsDispose($oSelf)
_GDIPlus_GraphicsDispose($oSelf.graphic)
EndFunc ;==>__OOPGDIP_GraphicsDispose
Func __OOPGDIP_GraphicsClear($oSelf)
_GDIPlus_GraphicsClear($oSelf.graphic)
EndFunc ;==>__OOPGDIP_GraphicsClear
Func _OOPGDIP_BufferCreate($Graphics, $width, $height, $clearcolor = 0xFF000000, $smooth = 0)
Local $Bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $Graphics.graphic)
Local $Context = _GDIPlus_ImageGetGraphicsContext($Bitmap)
_GDIPlus_GraphicsSetSmoothingMode($Context, $smooth)
Local $oGDIPBuffer = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPBuffer, "maingraphic", $ELSCOPE_PUBLIC, $Graphics.graphic)
_AutoItObject_AddProperty($oGDIPBuffer, "bitmap", $ELSCOPE_PUBLIC, Number($Bitmap))
_AutoItObject_AddProperty($oGDIPBuffer, "graphic", $ELSCOPE_PUBLIC, Number($Context))
_AutoItObject_AddProperty($oGDIPBuffer, "width", $ELSCOPE_PUBLIC, $width)
_AutoItObject_AddProperty($oGDIPBuffer, "height", $ELSCOPE_PUBLIC, $height)
_AutoItObject_AddProperty($oGDIPBuffer, "clearcolor", $ELSCOPE_PUBLIC, $clearcolor)
_AutoItObject_AddProperty($oGDIPBuffer, "smooth", $ELSCOPE_PUBLIC, $smooth)
_AutoItObject_AddMethod($oGDIPBuffer, "draw", "__OOPGDIP_BufferDraw")
_AutoItObject_AddMethod($oGDIPBuffer, "clear", "__OOPGDIP_BufferClear")
_AutoItObject_AddMethod($oGDIPBuffer, "update", "__OOPGDIP_BufferUpdate")
_AutoItObject_AddMethod($oGDIPBuffer, "dispose", "__OOPGDIP_BufferDispose")
Return $oGDIPBuffer
EndFunc ;==>_OOPGDIP_BufferCreate
Func __OOPGDIP_BufferUpdate($oSelf)
_GDIPlus_GraphicsSetSmoothingMode($oSelf.graphic, $oSelf.smooth)
EndFunc ;==>__OOPGDIP_BufferUpdate
Func __OOPGDIP_BufferDispose($oSelf)
_GDIPlus_GraphicsDispose($oSelf.graphic)
_GDIPlus_BitmapDispose($oSelf.bitmap)
EndFunc ;==>__OOPGDIP_BufferDispose
Func __OOPGDIP_BufferClear($oSelf)
_GDIPlus_GraphicsClear($oSelf.graphic, $oSelf.clearcolor)
EndFunc ;==>__OOPGDIP_BufferClear
Func __OOPGDIP_BufferDraw($oSelf)
_GDIPlus_GraphicsDrawImageRect($oSelf.maingraphic, $oSelf.bitmap, 0, 0, $oSelf.width, $oSelf.height)
EndFunc ;==>__OOPGDIP_BufferDraw
#EndRegion Graphic---------------------------------------------------------------------
;EndRegion Graphic------------------------------------------------------------------
#Region Zeichenobjekte--------------------------------------------------------------
Func _OOPGDIP_PenCreate($color, $width = 1, $unit = 2)
Local $GDIPPen = _GDIPlus_PenCreate($color, $width, $unit)
Local $oGDIPPen = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPPen, "handle", $ELSCOPE_PUBLIC, Number($GDIPPen))
_AutoItObject_AddProperty($oGDIPPen, "color", $ELSCOPE_PUBLIC, $color)
_AutoItObject_AddProperty($oGDIPPen, "width", $ELSCOPE_PUBLIC, $width)
_AutoItObject_AddProperty($oGDIPPen, "unit", $ELSCOPE_PUBLIC, $unit)
_AutoItObject_AddMethod($oGDIPPen, "update", "__OOPGDIP_PenUpdate")
_AutoItObject_AddMethod($oGDIPPen, "dispose", "__OOPGDIP_PenDispose")
Return $oGDIPPen
EndFunc ;==>_OOPGDIP_PenCreate
Func __OOPGDIP_PenDispose($oSelf)
_GDIPlus_PenDispose($oSelf.handle)
EndFunc ;==>__OOPGDIP_PenDispose
Func __OOPGDIP_PenUpdate($oSelf)
_GDIPlus_PenSetColor($oSelf.handle, $oSelf.color)
_GDIPlus_PenSetWidth($oSelf.handle, $oSelf.width)
EndFunc ;==>__OOPGDIP_PenUpdate
Func _OOPGDIP_BrushCreate($color)
Local $GDIPBrush = _GDIPlus_BrushCreateSolid($color)
Local $oGDIPBrush = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPBrush, "handle", $ELSCOPE_PUBLIC, Number($GDIPBrush))
_AutoItObject_AddProperty($oGDIPBrush, "color", $ELSCOPE_PUBLIC, $color)
_AutoItObject_AddMethod($oGDIPBrush, "update", "__OOPGDIP_BrushUpdate")
_AutoItObject_AddMethod($oGDIPBrush, "dispose", "__OOPGDIP_BrushDispose")
Return $oGDIPBrush
EndFunc ;==>_OOPGDIP_BrushCreate
Func __OOPGDIP_BrushDispose($oSelf)
_GDIPlus_BrushDispose($oSelf.handle)
EndFunc ;==>__OOPGDIP_BrushDispose
Func __OOPGDIP_BrushUpdate($oSelf)
_GDIPlus_BrushSetSolidColor($oSelf.handle, $oSelf.color)
EndFunc ;==>__OOPGDIP_BrushUpdate
Func _OOPGDIP_FontCreate($fSize, $sFamily = "Arial", $iStyle = 0, $Align = 0, $iFormat = 0, $iLangID = 0)
Local $hFamily = _GDIPlus_FontFamilyCreate($sFamily)
Local $hFont = _GDIPlus_FontCreate($hFamily, $fSize, $iStyle, 2)
Local $hFormat = _GDIPlus_StringFormatCreate($iFormat, $iLangID)
_GDIPlus_StringFormatSetAlign($hFormat, $Align)
Local $oGDIPFont = _AutoItObject_Create()
_AutoItObject_AddProperty($oGDIPFont, "handle", $ELSCOPE_PUBLIC, Number($hFont))
_AutoItObject_AddProperty($oGDIPFont, "hfamily", $ELSCOPE_PUBLIC, Number($hFamily))
_AutoItObject_AddProperty($oGDIPFont, "hformat", $ELSCOPE_PUBLIC, Number($hFormat))
_AutoItObject_AddProperty($oGDIPFont, "size", $ELSCOPE_PUBLIC, $fSize)
_AutoItObject_AddProperty($oGDIPFont, "fontname", $ELSCOPE_PUBLIC, $sFamily)
_AutoItObject_AddProperty($oGDIPFont, "style", $ELSCOPE_PUBLIC, $iStyle)
_AutoItObject_AddProperty($oGDIPFont, "align", $ELSCOPE_PUBLIC, $Align)
_AutoItObject_AddProperty($oGDIPFont, "format", $ELSCOPE_PUBLIC, $iFormat)
_AutoItObject_AddProperty($oGDIPFont, "langID", $ELSCOPE_PUBLIC, $iLangID)
_AutoItObject_AddMethod($oGDIPFont, "dispose", "__OOPGDIP_FontDispose")
_AutoItObject_AddMethod($oGDIPFont, "update", "__OOPGDIP_FontDispose")
Return $oGDIPFont
EndFunc ;==>_OOPGDIP_FontCreate
Func __OOPGDIP_FontDispose($oSelf)
_GDIPlus_FontDispose($oSelf.hanlde)
_GDIPlus_FontFamilyDispose($oSelf.hfamily)
_GDIPlus_StringFormatDispose($oSelf.hformat)
EndFunc ;==>__OOPGDIP_FontDispose
Func _OOPGDIP_FontUpdate($oSelf)
$oSelf.hfamily = Number(_GDIPlus_FontFamilyCreate($oSelf.fontname))
$oSelf.handle = Number(_GDIPlus_FontCreate($oSelf.family, $oSelf.size, $oSelf.style, 2))
$oSelf.hformat = Number(_GDIPlus_StringFormatCreate($oSelf.format, $oSelf.langID))
_GDIPlus_StringFormatSetAlign($oSelf.hformat, $oSelf.align)
EndFunc ;==>_OOPGDIP_FontUpdate
#EndRegion Zeichenobjekte--------------------------------------------------------------
;EndRegion Zeichenobjekte-----------------------------------------------------------
#Region Sonstiges-------------------------------------------------------------------
Func _OOPGDIP_Startup()
_AutoItObject_Startup()
_GDIPlus_Startup()
EndFunc ;==>_OOPGDIP_Startup
Func _OOPGDIP_Shutdown()
_AutoItObject_Shutdown()
_GDIPlus_Shutdown()
EndFunc ;==>_OOPGDIP_Shutdown
Func __OOPGDIP_TestRun()
Local $hGUI, $hImage
Local $oGDIPGraphic, $oGDIPLine, $oGDIPPen, $oGDIPBrush, $oGDIPRect, $oGDIPEllipse, $oGDIPFilledEllipse, $oGDIPFilledRect, $oGDIPPolygon, $oGDIPFilledPolygon, $oGDIPBuffer, $oGDIPPie, $oGDIPClosedCurve, $oGDIPFilledClosedCurve, $oGDIPCurve, $oGDIPBezier, $oGDIPImage, $oGDIPString, $oGDIPFont, $oGDIPStringEx[2]
Local $aPolygonCords[4][2] = [[3],[300, 30],[300, 160],[400, 160]]
Local $aCurveCords[5][2] = [[4],[20, 100],[50, 50],[100, 100],[150, 50]]
Local $ImageRotation = True
$hGUI = GUICreate("OOPGDIP = AutoIt + OOP + GDI+ ~-~ Funktionstest", 500, 500, -1, -1)
GUISetBkColor(0x6544AB)
GUISetState()
_OOPGDIP_Startup()
[/autoit] [autoit][/autoit] [autoit]$hImage = _GDIPlus_ImageLoadFromFile("NosHacks Logo_trans.png")
[/autoit] [autoit][/autoit] [autoit]$oGDIPGraphic = _OOPGDIP_GraphicsCreate($hGUI)
$oGDIPBuffer = _OOPGDIP_BufferCreate($oGDIPGraphic, 500, 500, 0xFF6544AB, 4)
$oGDIPPen = _OOPGDIP_PenCreate(0xFF00FF00)
$oGDIPBrush = _OOPGDIP_BrushCreate(0xFFFF0000)
$oGDIPLine = _OOPGDIP_LineCreate($oGDIPBuffer, 10, 40, 100, 200, $oGDIPPen)
$oGDIPRect = _OOPGDIP_RectCreate($oGDIPBuffer, 10, 40, 100, 200, $oGDIPPen)
$oGDIPEllipse = _OOPGDIP_EllipseCreate($oGDIPBuffer, 200, 200, 170, 100, $oGDIPPen, 0, 320)
$oGDIPPie = _OOPGDIP_PieCreate($oGDIPBuffer, 300, 300, 170, 100, $oGDIPPen, 0, 320)
$oGDIPFilledEllipse = _OOPGDIP_FilledEllipseCreate($oGDIPBuffer, 300, 300, 170, 100, $oGDIPBrush, 0, 320)
$oGDIPFilledRect = _OOPGDIP_FilledRectCreate($oGDIPBuffer, 10, 300, 200, 100, $oGDIPBrush)
$oGDIPPolygon = _OOPGDIP_PolygonCreate($oGDIPBuffer, $aPolygonCords, $oGDIPPen)
$oGDIPFilledPolygon = _OOPGDIP_FilledPolygonCreate($oGDIPBuffer, $aPolygonCords, $oGDIPBrush)
$oGDIPClosedCurve = _OOPGDIP_ClosedCurveCreate($oGDIPBuffer, $aPolygonCords, $oGDIPPen)
$oGDIPFilledClosedCurve = _OOPGDIP_FilledClosedCurveCreate($oGDIPBuffer, $aPolygonCords, $oGDIPBrush)
$oGDIPCurve = _OOPGDIP_CurveCreate($oGDIPBuffer, $aCurveCords, $oGDIPPen)
$oGDIPBezier = _OOPGDIP_BezierCreate($oGDIPBuffer, 30, 50, 100, 5, 125, 25, 250, 50, $oGDIPPen)
$oGDIPImage = _OOPGDIP_ImageCreate($oGDIPBuffer, $hImage, 10, 500 - 40)
$oGDIPString = _OOPGDIP_StringCreate($oGDIPBuffer, "Test", 100, 100, "Blackadder ITC", 100)
$oGDIPFont = _OOPGDIP_FontCreate(70, "Curlz MT", 1, 1)
$oGDIPStringEx[0] = _OOPGDIP_StringExCreate($oGDIPBuffer, "TestEx1", 0, 0, 400, 100, $oGDIPFont, $oGDIPBrush)
$oGDIPStringEx[1] = _OOPGDIP_StringExCreate($oGDIPBuffer, "TestEx2", 0, 100, 400, 100, $oGDIPFont, $oGDIPBrush)
While GUIGetMsg() <> -3
Sleep(20)
$oGDIPBuffer.clear
If $oGDIPImage.width1 >= -214 And $ImageRotation Then
$oGDIPImage.x1Pos = $oGDIPImage.x1Pos + 1
$oGDIPImage.width1 = $oGDIPImage.width1 - 2
If $oGDIPImage.width1 = -214 Then $ImageRotation = False
Else
$oGDIPImage.x1Pos = $oGDIPImage.x1Pos - 1
$oGDIPImage.width1 = $oGDIPImage.width1 + 2
If $oGDIPImage.width1 = 214 Then $ImageRotation = True
EndIf
$oGDIPImage.draw
$oGDIPLine.draw
$oGDIPRect.draw
$oGDIPFilledEllipse.sangle = $oGDIPFilledEllipse.sangle + 2
$oGDIPFilledEllipse.draw
$oGDIPEllipse.draw
$oGDIPPie.sangle = $oGDIPPie.sangle + 2
$oGDIPPie.draw
$oGDIPFilledRect.draw
$oGDIPFilledClosedCurve.draw
$oGDIPClosedCurve.draw
$oGDIPFilledPolygon.draw
$oGDIPPolygon.draw
$oGDIPCurve.draw
$oGDIPBezier.draw
$oGDIPString.draw
If $oGDIPStringEx[0] .xPos <= 200 Then $oGDIPStringEx[0] .xPos = $oGDIPStringEx[0] .xPos + 1
$oGDIPStringEx[0] .update
$oGDIPStringEx[0] .draw
If $oGDIPStringEx[1] .yPos <= 380 Then $oGDIPStringEx[1] .yPos = $oGDIPStringEx[1] .yPos + 1
$oGDIPStringEx[1] .update
$oGDIPStringEx[1] .draw
$oGDIPBuffer.draw
WEnd
_GDIPlus_ImageDispose($hImage)
[/autoit] [autoit][/autoit] [autoit]$oGDIPBrush.dispose
$oGDIPPen.dispose
$oGDIPBuffer.dispose
$oGDIPGraphic.dispose
_OOPGDIP_Shutdown()
Exit
EndFunc ;==>__OOPGDIP_TestRun
#EndRegion Sonstiges-------------------------------------------------------------------
;EndRegion Sonstiges----------------------------------------------------------------
Die AutoItObject.au3 muss in das Include-Verzeichnis, ansonsten funktioniert das Skript nicht!
AutoItObject.au3 - Download
Ich erbitte Feedback und viele Anregungen, wie ich das Skript verbessern kann.
MfG,
Nestos aka h2112.
ChangeLog
Edit:
1. Update - Mehr Formen verfügbar
Edit:
2. Update - Buffer umgesetzt und Dispose-Methoden umgesetzt
Edit:
3. Update - clearcolor hinzugefügt, Skript aufgeräumt und Beispiel hinzugefügt
Edit:
4. Update - String durch Number ersetzt - Danke an Progandy!
Edit:
5. Update - Alle Standardformen von GDI+ umgesetzt
Edit:
6. Update - Image umgesetzt
Edit:
7. Update - String umgesetzt
Edit:
8. Update - Font und StringEx umgesetzt
In dem Anhang ist enthalen:
AutoItObject.au3
OOPGDIP.au3
Beispiel - Kompletter Funktionsumfang.au3
NosHacks Logo_trans.png
PingPong.au3