Hallo Leutz,
ich hab schonwieder ein problem mit GDI+;
In den Vordergund werden Ellipsen gerendert (schnell).
Jetzt möchte ich im Hintergund ein Bild anzeigen.
Also schreibe ich das Bild in den Backbuffer.
Dann laufen 2 For-To Schleifen die Ellipsen zeichnen, die direkt danach wieder verschwinden sollen.
Um dies zu erreichen benutzte ich
[autoit]_GDIPlus_GraphicsClear
[/autoit]allerdings muss ich dann eine Farbe angeben.
Wenn ich 0xFFFFFFFF nehme fliegen die Ellipsen zwar ganz schnell allerdings ist der Hintergrund nicht sichtbar.
Wenn ich 0xFFFFFF nehme, verschwinden die Ellipsen nicht wieder.
Wenn ich den Hintergrund immer zusammen mit den Ellipsen in einen Buffer schreibe sind die Ellipsen zu langsam.
ich suche jetzt einen Weg den einzelnen Buffer zu leeren ohne die unteliegenden zu überschreiben;
Spoiler anzeigen
#include <GDIPlus.au3>
#include <GuiConstants.au3>
Opt("GuionEventmode",1)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$BackgroundBMP = _GDIPlus_BitmapCreateFromFile("background.jpg")
[/autoit] [autoit][/autoit] [autoit]$Width = 800
$Height = 600
$hWnd = GUICreate("test",$Width,$Height)
[/autoit] [autoit][/autoit] [autoit]GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
[/autoit] [autoit][/autoit] [autoit]GUISetState(@SW_SHOW)
[/autoit] [autoit][/autoit] [autoit]Global $hPen = _GDIPlus_PenCreate(0xFFFF0000,10)
[/autoit] [autoit][/autoit] [autoit]Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
[/autoit] [autoit][/autoit] [autoit]Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphics)
Global $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Global $hFGBitmap = _GDIPlus_BitmapCreateFromGraphics($Width,$Height, $hBackbuffer)
Global $hFGBackbuffer = _GDIPlus_ImageGetGraphicsContext($hFGBitmap)
;~ _GDIPlus_GraphicsDrawImageRect($hBackbuffer,$BackgroundBMP,0,0,$Width,$Height)
[/autoit] [autoit][/autoit] [autoit]$x1=0;
$y1=$Height
$x2=$width
$y2=$Height
$step=30
$clearcolor = 0xFFFFFF
While 1
$Mouse = GUIGetCursorInfo($hWnd)
If $Mouse[2] = 1 Then
$m1=($mouse[1]-$y1)/($mouse[0]-$x1)
$b1=$mouse[1]-$m1*$mouse[0]
$m2=($mouse[1]-$y2)/($mouse[0]-$x2)
$b2=$mouse[1]-$m2*$mouse[0]
;~ _GDIPlus_GraphicsDrawImageRect($hBackbuffer,$BackgroundBMP,0,0,$Width,$Height)
[/autoit] [autoit][/autoit] [autoit]for $x=$x1 to $mouse[0] step $step
$y=$m1*$x+$b1
_GDIPlus_GraphicsClear($hFGBackbuffer,$clearcolor)
_GDIPlus_GraphicsDrawEllipse($hFGBackbuffer, $x, $y, 5, 5,$hPen)
;~ _GDIPlus_GraphicsDrawImageRect($hBackbuffer,$BackgroundBMP,0,0,$Width,$Height)
_GDIPlus_GraphicsDrawImageRect($hBackbuffer,$hFGBitmap,0,0,$Width,$Height)
_GDIPlus_GraphicsDrawImageRect($hGraphics,$hBitmap,0,0,$Width,$Height)
next
for $x=$x2 to $mouse[0] step -$step
$y=$m2*$x+$b2
_GDIPlus_GraphicsClear($hFGBackbuffer,$clearcolor)
_GDIPlus_GraphicsDrawEllipse($hFGBackbuffer, $x, $y, 5, 5,$hPen)
;~ _GDIPlus_GraphicsDrawImageRect($hBackbuffer,$BackgroundBMP,0,0,$Width,$Height)
_GDIPlus_GraphicsDrawImageRect($hBackbuffer,$hFGBitmap,0,0,$Width,$Height)
_GDIPlus_GraphicsDrawImageRect($hGraphics,$hBitmap,0,0,$Width,$Height)
next
Else
_GDIPlus_GraphicsClear($hFGBackbuffer,$clearcolo)
_GDIPlus_GraphicsDrawImageRect($hBackbuffer,$BackgroundBMP,0,0,$Width,$Height)
_GDIPlus_GraphicsDrawImageRect($hBackbuffer,$hFGBitmap,0,0,$Width,$Height)
_GDIPlus_GraphicsDrawImageRect($hGraphics,$hBitmap,0,0,$Width,$Height)
EndIf
WEnd
Func _Exit()
_GDIPlus_Shutdown()
Exit
EndFunc