- Offizieller Beitrag
Wie kann man eine mit GDI+ erstellte Graphic abspeichern?
Das hier klappt nicht:
Spoiler anzeigen
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
$hGui1 = GUICreate('test', 540, 540, -1, 0)
_GDIPlus_Startup ()
$hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(WinGetHandle($hGui1))
_GDIPlus_GraphicsSetSmoothingMode($hGraphic1, 2)
$hPen = _GDIPlus_PenCreate(0xcc000000, 2)
Global $ahBrush[4]
$ahBrush[0] = _GDIPlus_BrushCreateSolid(0xffffffff)
$ahBrush[1] = _GDIPlus_BrushCreateSolid(0xff42b8c8)
$ahBrush[2] = _GDIPlus_BrushCreateSolid(0xffff1a10)
$ahBrush[3] = _GDIPlus_BrushCreateSolid(0xfffef433)
GUIRegisterMsg($WM_PAINT, 'MY_WM_PAINT')
GUISetState()
If FileExists(@ScriptDir & '\pic.jpg') Then FileDelete(@ScriptDir & '\pic.jpg')
[/autoit] [autoit][/autoit] [autoit]; wie kann man die erzeugte Graphic in eine Datei speichern?
$hImage1 = _GDIPlus_BitmapCreateFromGraphics(540, 540, $hGraphic1) ; das hier
_GDIPlus_ImageSaveToFile($hImage1, @ScriptDir & '\pic.jpg') ; klappt nicht.
Do
Until GUIGetMsg() = -3
_GDIPlus_PenDispose($hPen)
For $i = 0 To UBound($ahBrush) -1
_GDIPlus_BrushDispose($ahBrush[$i])
Next
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_GraphicsDispose($hGraphic1)
_GDIPlus_Shutdown()
Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
_GDIPlus_GraphicsFillRect($hGraphic1, 0, 0, 540, 540, $ahBrush[0])
_GDIPlus_GraphicsDrawEllipse($hGraphic1, 30, 30, 480, 480, $hPen)
_GDIPlus_GraphicsFillEllipse($hGraphic1, 31, 31, 478, 478, $ahBrush[0])
_GDIPlus_GraphicsDrawEllipse($hGraphic1, 54, 54, 432, 432, $hPen)
_GDIPlus_GraphicsFillEllipse($hGraphic1, 55, 55, 430, 430, $ahBrush[0])
_GDIPlus_GraphicsFillEllipse($hGraphic1, 78, 78, 384, 384)
_GDIPlus_PenSetColor($hPen, 0xddffffff)
_GDIPlus_GraphicsDrawEllipse($hGraphic1, 102, 102, 336, 336, $hPen)
_GDIPlus_GraphicsFillEllipse($hGraphic1, 103, 103, 334, 334)
_GDIPlus_PenSetColor($hPen, 0xcc000000)
_GDIPlus_GraphicsDrawEllipse($hGraphic1, 126, 126, 288, 288, $hPen)
_GDIPlus_GraphicsFillEllipse($hGraphic1, 127, 127, 286, 286, $ahBrush[1])
_GDIPlus_GraphicsDrawEllipse($hGraphic1, 150, 150, 240, 240, $hPen)
_GDIPlus_GraphicsFillEllipse($hGraphic1, 151, 151, 238, 238, $ahBrush[1])
_GDIPlus_GraphicsDrawEllipse($hGraphic1, 174, 174, 192, 192, $hPen)
_GDIPlus_GraphicsFillEllipse($hGraphic1, 175, 175, 190, 190, $ahBrush[2])
_GDIPlus_GraphicsDrawEllipse($hGraphic1, 198, 198, 144, 144, $hPen)
_GDIPlus_GraphicsFillEllipse($hGraphic1, 199, 199, 142, 142, $ahBrush[2])
_GDIPlus_GraphicsDrawEllipse($hGraphic1, 222, 222, 96, 96, $hPen)
_GDIPlus_GraphicsFillEllipse($hGraphic1, 223, 223, 94, 94, $ahBrush[3])
_GDIPlus_GraphicsDrawEllipse($hGraphic1, 246, 246, 48, 48, $hPen)
_GDIPlus_GraphicsFillEllipse($hGraphic1, 247, 247, 46, 46, $ahBrush[3])
_GDIPlus_PenSetColor($hPen, 0xcc000000)
_GDIPlus_GraphicsDrawEllipse($hGraphic1, 258, 258, 24, 24, $hPen)
_GDIPlus_GraphicsFillEllipse($hGraphic1, 259, 259, 22, 22, $ahBrush[3])
_GDIPlus_GraphicsDrawLine($hGraphic1, 266, 270, 274, 270, $hPen)
_GDIPlus_GraphicsDrawLine($hGraphic1, 270, 266, 270, 274, $hPen)
Return $GUI_RUNDEFMSG
EndFunc