GDI Plus Problem

  • Hab heute nun auch mal mit GDI+ angefangen. Schon das 1. Problem.

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <Misc.au3>
    Global $x=20, $y=180
    Const $Width=15, $Height=15
    HotKeySet("{ESC}", "quit")
    _GDIPlus_Startup()
    $hGUI = GUICreate("Test", 354, 210, 192, 124, 0x80000000+0x00800000)
    $hGraphics=_GDIPlus_GraphicsCreateFromHWND($hGUI)
    GUISetBkColor(0x000000)
    GUISetState(@SW_SHOW)
    $Pen1=_GDIPlus_PenCreate(0xFFFFFFFF)
    _GDIPlus_GraphicsDrawPie($hGraphics, $x, $y, $Width, $Height, 0, 180, $Pen1)
    While 1
    Switch GUIGetMsg()
    Case -3
    quit()
    EndSwitch
    If _isPressed(27) And $x<314 Then
    $x+=1
    _GDIPlus_GraphicsClear($hGraphics)
    _GDIPlus_GraphicsDrawPie($hGraphics, $x, $y, $Width, $Height, 0, 180, $Pen1)
    EndIF
    If _isPressed(25) And $x>20 Then
    $x-=1
    _GDIPlus_GraphicsClear($hGraphics)
    _GDIPlus_GraphicsDrawPie($hGraphics, $x, $y, $Width, $Height, 0, 180, $Pen1)
    EndIF
    WEnd
    Func quit()
    _GDIPlus_PenDispose($Pen1)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc

    [/autoit]


    Wenn ich nun den Halbkreis bewegen will (linke und rechte Pfeiltaste), flackert es ziemlich stark. Ich hab mal ab und zu gelesen, dass man den Buffer benutzen muss/soll, hab aber leider keine Ahnung, wie ich das machen soll. Wie gesagt, bin noch sehr neu in GDI+.

    Einmal editiert, zuletzt von Ineluki (21. Juli 2010 um 17:50)

  • Ich krieg das immernoch nicht hin :(

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <Misc.au3>
    Global $x=20, $y=180
    Const $Width=15, $Height=15
    HotKeySet("{ESC}", "quit")
    _GDIPlus_Startup()
    $hGUI = GUICreate("Test", 354, 210, 192, 124, 0x80000000+0x00800000)
    $hGraphics=_GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics(354, 210, $hGraphics)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    GUISetBkColor(0x000000)
    GUISetState(@SW_SHOW)
    $Pen1=_GDIPlus_PenCreate(0xFFFFFFFF)
    _GDIPlus_GraphicsDrawPie($hGraphics, $x, $y, $Width, $Height, 0, 180, $Pen1)
    While 1
    Switch GUIGetMsg()
    Case -3
    quit()
    EndSwitch
    If _isPressed(27) And $x<314 Then
    $x+=1
    _GDIPlus_GraphicsClear($hGraphics)
    _GDIPlus_GraphicsClear($hBuffer)
    _GDIPlus_GraphicsDrawPie($hBuffer, $x, $y, $Width, $Height, 0, 180, $Pen1)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, 354, 210)
    EndIF
    If _isPressed(25) And $x>20 Then
    $x-=1
    _GDIPlus_GraphicsClear($hGraphics)
    _GDIPlus_GraphicsClear($hBuffer)
    _GDIPlus_GraphicsDrawPie($hBuffer, $x, $y, $Width, $Height, 0, 180, $Pen1)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, 354, 210)
    EndIF
    WEnd
    Func quit()
    _GDIPlus_PenDispose($Pen1)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    Exit
    EndFunc

    [/autoit]


    Es flackert immer noch. Ich bin mir ziemlich sicher, dass ich irgendwas im Tut falsch verstanden habe. Nur was?
    Edit: geht jetzt:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <Misc.au3>
    Global $x=20, $y=180
    Const $Width=15, $Height=15
    HotKeySet("{ESC}", "quit")
    _GDIPlus_Startup()
    $hGUI = GUICreate("Test", 354, 210, 192, 124, 0x80000000+0x00800000)
    $hGraphics=_GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics(354, 210, $hGraphics)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    GUISetBkColor(0x000000)
    GUISetState(@SW_SHOW)
    $Pen1=_GDIPlus_PenCreate(0xFFFFFFFF)
    _GDIPlus_GraphicsDrawPie($hGraphics, $x, $y, $Width, $Height, 0, 180, $Pen1)
    While 1
    Switch GUIGetMsg()
    Case -3
    quit()
    EndSwitch
    If _isPressed(27) And $x<314 Then
    $x+=1
    _GDIPlus_GraphicsClear($hBuffer)
    _GDIPlus_GraphicsDrawPie($hBuffer, $x, $y, $Width, $Height, 0, 180, $Pen1)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, 354, 210)
    EndIF
    If _isPressed(25) And $x>20 Then
    $x-=1
    _GDIPlus_GraphicsClear($hBuffer)
    _GDIPlus_GraphicsDrawPie($hBuffer, $x, $y, $Width, $Height, 0, 180, $Pen1)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, 354, 210)
    EndIF
    WEnd
    Func quit()
    _GDIPlus_PenDispose($Pen1)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    Exit
    EndFunc

    [/autoit]


    Danke

    Einmal editiert, zuletzt von Ineluki (21. Juli 2010 um 17:49)