Moin alle ![]()
Ich hab ne Frage:
Gibt es irgendwie eine Möglichkeit, das Flackern beim überzeichnen von GDI+ Graphiken zu unterbinden?
In meinem Fall liegen zwei Graphiken, die teilweiße transparente PNGs enthalten direkt übereinander und diese werden immer wieder neu gezeichnet. Nur da Flackert halt das ganze ziemlich. ![]()
Danke schonmal im Vorraus. ![]()
Edit
Hier das Skript:
Skript
#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
#Include <WinAPI.au3>
#include <Array.au3>
#include <Misc.au3>
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]Global $MoveX = 0
Global $MoveY = 0
Global $hImage = _GDIPlus_ImageLoadFromFile(@DesktopDir&"\DieWelt.png")
Global $hFigurImage = _GDIPlus_ImageLoadFromFile(@DesktopDir&"\Anathema-Priestess.png")
Global $MapWidth = 22
Global $MapHeigth = 15
Global $hGraphic1, $hGUI
Global $MainFigurPoxX = 10
Global $MainFigurPoxY = 8
$hGUI = GUICreate("Map1", 324, 244, -1, -1, 0x14CA0000, 0x00050100)
GUISetBkColor(0x000000, $hGUI)
GUISetState()
$hGraphic1 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hGraphic2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_DrawMultiMap(1 - $MoveX, 1, 20, 15, 1, 6)
_DrawMainFigure($MainFigurPoxX, $MainFigurPoxY)
Do
_Moveing()
Sleep(200)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
_GDIPlus_GraphicsDispose($hGraphic1)
_GDIPlus_GraphicsDispose($hGraphic2)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
[/autoit] [autoit][/autoit] [autoit]Func _DrawMap($Position1, $Position2, $Pic1, $Pic2)
;~ DllCall($ghGDIPDll, "int", "GdipDrawImageRectRectI", "hwnd", $hGraphic1, "hwnd", $hImage, "int", 2 + ($Position1 - 1) * 15 + ($Position1 - 1), "int", _
;~ 2 + ($Position2 - 1) * 15 + ($Position2 - 1), "int", 16, "int", 16, "int", ($Pic1 - 1) * 16, "int", ($Pic2 - 1) * 16, "int", 16, "int", _
;~ 16, "int", 2, "int", 0, "int", 0, "int", 0)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic1, $hImage, ($Pic1 - 1) * 16, ($Pic2 - 1) * 16, 16, 16, 2 + ($Position1 - 1) * 15 + ($Position1 - 1), 2 + ($Position2 - 1) * 15 + ($Position2 - 1), 16, 16)
EndFunc
Func _DrawMultiMap($Position1, $Position2, $Width, $Heigth, $Pic1, $Pic2)
For $i = 0 To $Width Step + 1
For $j = 0 To $Heigth Step + 1
_DrawMap($Position1 + $i - 1, $Position2 + $j - 1, $Pic1, $Pic2)
Next
Next
EndFunc
Func _Moveing()
Select
Case _IsPressed(27) = 1
_Right()
Case _IsPressed(25) = 1
_Left()
EndSelect
EndFunc
Func _Right()
If $MainFigurPoxX < 10 Then
$MainFigurPoxX += 1
ElseIf $MoveX <= $MapWidth - 21 Then
$MoveX += 1
Else
If $MainFigurPoxX < 20 Then
$MainFigurPoxX += 1
EndIf
EndIf
_WinAPI_RedrawWindow_($hGUI)
_DrawMultiMap(1 - $MoveX, 1, 20, 15, 1, 6)
_DrawMainFigure($MainFigurPoxX, $MainFigurPoxY)
EndFunc
Func _Left()
If $MainFigurPoxX > 10 Then
$MainFigurPoxX -= 1
ElseIf Not $MoveX = 0 Then
$MoveX -= 1
Else
If $MainFigurPoxX >1 Then $MainFigurPoxX -= 1
EndIf
_WinAPI_RedrawWindow_($hGUI)
_DrawMultiMap(1 - $MoveX, 1, 20, 15, 1, 6)
_DrawMainFigure($MainFigurPoxX, $MainFigurPoxY)
EndFunc
Func _WinAPI_RedrawWindow_($hWnd)
DllCall("user32.dll", "int", "RedrawWindow", "hwnd", $hWnd, "ptr", 0, "int", 0, "int", 5)
EndFunc ;==>_WinAPI_RedrawWindow
Func _DrawMainFigure($Position1, $Position2)
;~ DllCall($ghGDIPDll, "int", "GdipDrawImageRectRectI", "hwnd", $hGraphic2, "hwnd", $hFigurImage, "int", ($Position1 -1) * 16 - 2, "int", _
;~ ($Position2 - 1) * 16, "int", 24, "int", 32, "int", 24, "int", 64, "int", 24, "int", _
;~ 32, "int", 2, "int", 0, "int", 0, "int", 0)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic2, $hFigurImage, 24, 64, 24, 32, ($Position1 -1) * 16 - 2, ($Position2 - 1) * 16, 24, 32)
EndFunc