GDI+ gezeichnetes png wird bei WM_PAINT kantig?!

  • Hallo:

    In diesem .rar hier findet ihr ein png Bild und das Script.
    http://www.box.net/shared/2z98a50mhi

    Im GUI soll dieses PNG angezeigt werden - klappt auch.
    Wenn man jetzt allerdings das GUI aus dem Desktop rausschiebt,
    und dann wieder reinzieht, wird die ganze Grafik irgendwie "kantig."
    Vorher:
    Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.
    Nachher:
    Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.

    Als ob GDI die Kantenglättung ausschaltet.

    Kann mir einer sagen warum das so ist?

    Hier nochmal das Script, falls jemand das .rar nicht runterladen möchte:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <WinAPI.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $hGUI = GUICreate("DescribeIt Installer", 470, 260, -1, -1)
    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\describeit.png")
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    [/autoit] [autoit][/autoit] [autoit]

    $idDestination = GUICtrlCreateGroup("Destination path", 16, 96, 433, 49)
    $idPath = GUICtrlCreateInput("", 24, 112, 321, 21)
    $id_browse = GUICtrlCreateButton("Browse...", 352, 112, 89, 25, $WS_GROUP)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $idText = GUICtrlCreateLabel( _
    "Setup will now install DescribeIt on your computer. Please your installation directory below." & @CRLF & _
    "If the selected directory does not exist, it will be created.", 16, 152, 427, 50)
    $idInstall = GUICtrlCreateButton("Start Installation", 304, 216, 145, 33, $WS_GROUP)
    $idExit = GUICtrlCreateButton("Exit Installation", 16, 216, 137, 33, $WS_GROUP)

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; Draw PNG image
    Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 10,-40)
    _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>MY_WM_PAINT

    [/autoit]

    <- Vista 32 Bit.

  • Probiere das mal:

    Spoiler anzeigen
    [autoit]


    #include <GDIPlus.au3>
    #include <WinAPI.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $w = 470
    $h = 260
    $hGUI = GUICreate("DescribeIt Installer", $w, $h, -1, -1)
    $GUI_Back_Color = 0xF0F0F0
    GUISetBkColor($GUI_Back_Color)
    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\describeit.png")
    $iX = _GDIPlus_ImageGetWidth($hImage)
    $iY = _GDIPlus_ImageGetHeight($hImage) - 4
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $GUI_Back_Color)

    [/autoit] [autoit][/autoit] [autoit]

    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($w, $h, $hGraphic)
    $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    [/autoit] [autoit][/autoit] [autoit]

    $idDestination = GUICtrlCreateGroup("Destination path", 16, 96, 433, 49)
    $idPath = GUICtrlCreateInput("", 24, 112, 321, 21)
    $id_browse = GUICtrlCreateButton("Browse...", 352, 112, 89, 25, $WS_GROUP)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $idText = GUICtrlCreateLabel( _
    "Setup will now install DescribeIt on your computer. Please your installation directory below." & @CRLF & _
    "If the selected directory does not exist, it will be created.", 16, 152, 427, 50)
    $idInstall = GUICtrlCreateButton("Start Installation", 304, 216, 145, 33, $WS_GROUP)
    $idExit = GUICtrlCreateButton("Exit Installation", 16, 216, 137, 33, $WS_GROUP)

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
    _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INTERNALPAINT)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_Shutdown()
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; Draw PNG image
    Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
    _GDIPlus_GraphicsFillRect($hBackbuffer, 0, 0, 470, $iY, $hBrush)
    _GDIPlus_GraphicsDrawImage($hBackbuffer, $hImage, 10, -40)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $w, $h)
    _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>MY_WM_PAINT

    [/autoit]

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

    3 Mal editiert, zuletzt von UEZ (8. März 2010 um 00:09)