tinman_72 Posted October 14, 2017 Share Posted October 14, 2017 I have a GUI which I am using GUICtrlCreatePic to display a JPEG. For some reason in the GUI it is garbled but all programs I open it with show it properly. I have tried converting it to a bitmap with the same issue. The code I am using is pretty straight forward: Local $hGUIChoose = GUICreate ( "Title", 400, 250 ) GUISetBkColor ( 0x004e99, $hGUIChoose ) GUICtrlCreateLabel ( "Some text", 10, 10, 380 ) GUICtrlSetFont ( -1, 10, 600, 0, "", 5 ) GUICtrlSetColor ( -1, 0x80c0ff ) GUICtrlCreatePic ( @TempDir & "\click_here.bmp", 81, 80, 0, 0 ) I have included a snapshot of the GUI with the garbled image next to the file displayed in Window's viewer. I have also attached a copy of the source JPEG. Any insight would be very much appreciated. Link to comment Share on other sites More sharing options...
tinman_72 Posted October 14, 2017 Author Share Posted October 14, 2017 I have been struggling with this for hours. After I posted this I tried removing the background color of the GUI. This seems to have fixed the problem. So how can I display an image within a GUI that has a background color defined? Link to comment Share on other sites More sharing options...
genius257 Posted October 15, 2017 Share Posted October 15, 2017 Hi @tinman_72. My suggestion, is to use GDI+ I'm sure there is a way to make it work the other way, but this was quicker for me expandcollapse popup#include <GDIPlus.au3> Opt("GuiOnEventMode", 1) _GDIPlus_Startup() $hBitmap = _GDIPlus_ImageLoadFromFile("click_here.jpg") GUIRegisterMsg(0x000F, "WM_PAINT") Local $hGUIChoose = GUICreate ( "Title", 400, 250 ) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUIChoose) GUISetState() GUISetBkColor ( 0x004e99, $hGUIChoose ) GUICtrlCreateLabel ( "Some text", 10, 10, 380 ) GUICtrlSetFont ( -1, 10, 600, 0, "", 5 ) GUICtrlSetColor ( -1, 0x80c0ff ) OnAutoItExitRegister("CleanUp") GUISetOnEvent(-3, "MyExit", $hGUIChoose) While 1 Sleep(10) WEnd Func WM_PAINT($hWnd, $iMsg, $wParam, $lParam) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 81, 80, 238, 157) EndFunc Func CleanUp() _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_Shutdown() EndFunc Func MyExit() Exit EndFunc Hope this helps My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser Link to comment Share on other sites More sharing options...
tinman_72 Posted October 17, 2017 Author Share Posted October 17, 2017 Thanks. I've looked over GDI+ before and had trouble understanding it. Guess I have some reading to do. Link to comment Share on other sites More sharing options...
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