AustrianOak Posted June 14, 2008 Posted June 14, 2008 I've tried in several cases to use a p.ng file in my program and was unsuccessful. I would try it with GUICtrlCreatePic() and GUICtrlSetImage and so forth. Everytime I would try to use a .png it would just put a blank space wherever the image was supposed to be. does autoit support png's?
sandin Posted June 14, 2008 Posted June 14, 2008 PNGs are supported:http://www.autoitscript.com/forum/index.ph...7651&hl=pnghttp://www.autoitscript.com/forum/index.ph...3225&hl=png Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll
monoceres Posted June 14, 2008 Posted June 14, 2008 GDI+ is the key: #include <GDIPlus.au3> #include <WinAPI.au3> _GDIPlus_Startup() $image=_GDIPlus_ImageLoadFromFile("image.png") _GDIPlus_ImageSaveToFile($image,"image.jpg") _WinAPI_DeleteObject($image) GUICreate("test",300,300) GUICtrlCreatePic("image.jpg",10,10) GUISetState() Do $msg=GUIGetMsg() Until $msg=-3 _GDIPlus_Shutdown() Broken link? PM me and I'll send you the file!
AustrianOak Posted June 14, 2008 Author Posted June 14, 2008 (edited) So it converts it over to a .jpg? My image is very deformed in the gui?... And it lost ALL of its glossiness, and resolution... I wanted to use .png in the first place so I could have really good looking images. Edited June 14, 2008 by nowagain
monoceres Posted June 14, 2008 Posted June 14, 2008 So it converts it over to a .jpg?My image is very deformed in the gui?...And it lost ALL of its glossiness, and resolution...I wanted to use .png in the first place so I could have really good looking images.Change to .bmp Broken link? PM me and I'll send you the file!
monoceres Posted June 14, 2008 Posted June 14, 2008 (edited) Or you could paint the control yourself #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> _GDIPlus_Startup() $image = _GDIPlus_ImageLoadFromFile("image.png") $hwnd = GUICreate("test", 300, 300) GUICtrlCreatePic("", 10, 10, 280, 280) GUISetState() GUIRegisterMsg($WM_PAINT, "_ReDraw") $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) _GDIPlus_GraphicsDrawImageRect($graphics, $image, 10, 10, 280, 280) Do $msg = GUIGetMsg() Until $msg = -3 _WinAPI_DeleteObject($image) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() Func _ReDraw() _GDIPlus_GraphicsDrawImageRect($graphics, $image, 10, 10, 280, 280) Return $GUI_RUNDEFMSG EndFunc ;==>_ReDraw Edited June 14, 2008 by monoceres shotiko 1 Broken link? PM me and I'll send you the file!
AustrianOak Posted June 26, 2008 Author Posted June 26, 2008 Or you could paint the control yourself #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> _GDIPlus_Startup() $image = _GDIPlus_ImageLoadFromFile("image.png") $hwnd = GUICreate("test", 300, 300) GUICtrlCreatePic("", 10, 10, 280, 280) GUISetState() GUIRegisterMsg($WM_PAINT, "_ReDraw") $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) _GDIPlus_GraphicsDrawImageRect($graphics, $image, 10, 10, 280, 280) Do $msg = GUIGetMsg() Until $msg = -3 _WinAPI_DeleteObject($image) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() Func _ReDraw() _GDIPlus_GraphicsDrawImageRect($graphics, $image, 10, 10, 280, 280) Return $GUI_RUNDEFMSG EndFunc;==>_ReDraw When I use this method whenever I move around my window a blackish border expands around my image and stays there. then i minimize it and it goes a way, but then re-appears when i move my window again...?
AustrianOak Posted June 26, 2008 Author Posted June 26, 2008 Here's the code I am using: #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> _GDIPlus_Startup() $image = _GDIPlus_ImageLoadFromFile("glass.png") $hwnd = GUICreate("", 500, 500) GUICtrlCreatePic("", 20, 20, 24, 26) GUISetBkColor(0xeef2fd, $hwnd) GUISetState() GUIRegisterMsg($WM_PAINT, "_ReDraw") $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) _GDIPlus_GraphicsDrawImageRect($graphics, $image, 20, 20, 24, 26) Do $msg = GUIGetMsg() Until $msg = -3 _WinAPI_DeleteObject($image) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() Func _ReDraw() _GDIPlus_GraphicsDrawImageRect($graphics, $image, 20, 20, 24, 26) Return $GUI_RUNDEFMSG EndFunc;==>_ReDraw When I run it and move the window containing my .png image a black border forms around it. Is is the re-drawing function? I'm lost and also very new with this GDI+ stuff.
AustrianOak Posted June 26, 2008 Author Posted June 26, 2008 Bump. Does anyone need to see a screenshot?
monoceres Posted June 26, 2008 Posted June 26, 2008 Try something like: #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> _GDIPlus_Startup() $image = _GDIPlus_ImageLoadFromFile("glass.png") $hwnd = GUICreate("", 500, 500) GUICtrlCreatePic("", 22, 22, 20, 22); Changed here GUISetBkColor(0xeef2fd, $hwnd) GUISetState() GUIRegisterMsg($WM_PAINT, "_ReDraw") $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) _GDIPlus_GraphicsDrawImageRect($graphics, $image, 20, 20, 24, 26) Do $msg = GUIGetMsg() Until $msg = -3 _WinAPI_DeleteObject($image) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() Func _ReDraw() _GDIPlus_GraphicsDrawImageRect($graphics, $image, 20, 20, 24, 26) Return $GUI_RUNDEFMSG EndFunc;==>_ReDraw Broken link? PM me and I'll send you the file!
AustrianOak Posted June 27, 2008 Author Posted June 27, 2008 As far as I can see it looks like its solved, but I don't understand why... You changed the width and height (24,26) to 20,22. How did that fix it?
ChangMinYang Posted February 21, 2009 Posted February 21, 2009 As far as I can see it looks like its solved, but I don't understand why...You changed the width and height (24,26) to 20,22. How did that fix it?Difference by 'GUI Border Width' added, or not.
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