taotao878 Posted April 30, 2008 Posted April 30, 2008 (edited) expandcollapse popup#include <GUIConstants.au3> #include <GDIPlus.au3> #Include <WinAPI.au3> Opt("MustDeclareVars", 1) Global $hGUI, $hImage, $hGraphic, $hImage1 ; Create GUI $hGUI = GUICreate("Show PNG", 260, 260) GUISetState() ; Load PNG image _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile("MAIN.png") ; Draw PNG image $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 50, 50) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") ; Loop until user exits do until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 50, 50) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc Edited April 30, 2008 by taotao878
Zedna Posted April 30, 2008 Posted April 30, 2008 (edited) Little optimized version: #include <GUIConstants.au3> #include <GDIPlus.au3> #Include <WinAPI.au3> Opt("MustDeclareVars", 1) Global $hGUI, $hImage, $hGraphic, $hImage1 ; Create GUI $hGUI = GUICreate("Show PNG", 260, 260) ; Load PNG image _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile("MAIN.png") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") GUISetState() ; Loop until user exits do until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() ; Draw PNG image Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 50, 50) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc Edited April 30, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
taotao878 Posted April 30, 2008 Author Posted April 30, 2008 expandcollapse popup#include <GuiConstantsEX.au3> #include <GDIPlus.au3> Global $hGui, $iExt Global $hPic, $hImage, $hGraphic $hGui = GUICreate("show png", 350, 300) $Button = GUICtrlCreateButton ("view", 270, 270, 75, 21) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $Button $OpenFile = FileOpenDialog("Select png file", "", "png(*.png)") _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile($OpenFile) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") EndSwitch WEnd _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc It have problem to show png with GDI+, likes attachment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now