Jump to content
Sign in to follow this  
timmy2

random visual glitch when using GUICtrlSetImage

Recommended Posts

timmy2

I'm displaying a series of BMP images using AutoIt's GUI capabilities.

Here's my initial test code. All it does is test my goal of displaying a picture, then allowing some code to accomplish a brief task, followed by the next picture, etc. The problem I'm having is that sometimes there's a brief visual glitch in the picture when GUICtrlSetImage displays the next picture. This doesn't happen every time but it happens enough to make the result look funky.

Any suggestions about what I can do to prevent the glitch? Could it be the specs of the BMP images I'm creating in Photoshop CS6?  Under BMP Options I'm using 24 Bit depth, no RLE compression -- ie., the defaults. (note that I've tried using jpg's instead of bmp file without improvement)

$form=GUICreate("PowerStrips",900,530,518,272, BitOR($WS_SYSMENU,$WS_POPUP), 0)
$cid=GUICtrlCreatePic(@ScriptDir & "\imagebackground.bmp", 0,0, 900, 530)
GuiCtrlSetState($cid,$GUI_DISABLE)

;The initial "button" I want to show
$PSimage=GUICtrlCreatePic(@ScriptDir & "\image1.bmp", 0,0,900,530)

GUISetState(@SW_SHOW)  ;show 1st image
MsgBox(0,"","test")

GUICtrlSetImage($PSimage, @ScriptDir & "\image2.bmp") ;show 2nd image
MsgBox(0,"","test")

GUICtrlSetImage($PSimage,@ScriptDir & "\image3.bmp")  ;show 3rd image
MsgBox(0,"","test")

GUICtrlSetImage($PSimage,@ScriptDir & "\image4.bmp")  'show 4th image
MsgBox(0,"","test")

Exit
Edited by timmy2

Share this post


Link to post
Share on other sites
timmy2

After trying various alternative scripting approaches I tried my script on another computer. No white flashes, tears, glitches. So I brought it back to my main box and disabled the Intel GPU that was feeding a 3rd monitor. Down to two monitors connected to a single NVidia GPU the visual glitches disappeared.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • Bilgus
      By Bilgus
      @TexWiller asked in Help & Support how to use _WinAPI_ExtractIconEx instead of GUICtrlSetImage
      This is his reproducer script for displaying his issue I cleaned it up and made it work for _WinAPI_ExtractIconEx
      ;============================================================================================================ ;Program Options ;============================================================================================================ Opt("MustDeclareVars", 1) ;Variables must be pre-declared. Opt("TrayMenuMode", 3) ;The default tray menu items will not be shown, items are not checked when selected. ;============================================================================================================ ;Libraries Inclusions ;============================================================================================================ #include <ColorConstants.au3> #include <TrayConstants.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <GuiConstantsEx.au3> #include <Array.au3> #include <GuiButton.au3> #include <StaticConstants.au3> ;============================================================================================================ ;Global Vars ;============================================================================================================ Global $hMainGUI Global $nMsg Global $IdTrayMenuMain Global $IdTrayMenuExit Main() Func Main() ;------------------------------------------------------------------------------------------------------------ ;Create Main Window ;------------------------------------------------------------------------------------------------------------ $hMainGUI = GUICreate("Sample", 1024, 700, 50, 50, BitOR($WS_SYSMENU, $WS_CAPTION, $DS_SETFOREGROUND)) GUISetFont(8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $hMainGUI, $CLEARTYPE_QUALITY) GUISetBkColor(0xDDDDDD, $hMainGUI) GUISetState(@SW_SHOW, $hMainGUI) WinWaitActive($hMainGUI) ;============================================================================================================ ;Create Traymenu ;============================================================================================================ ;Create a Traymenu. $IdTrayMenuMain = TrayCreateItem("Sample", -1, 0) ;Create a Separator line. TrayCreateItem("", -1, -1) ;Create a Menuitem. $IdTrayMenuExit = TrayCreateItem("Exit", -1, -1) ;Show the Traymenu. TraySetState($TRAY_ICONSTATE_SHOW) ;------------------------------------------------------------------------------------------------------------ ;Sample ;------------------------------------------------------------------------------------------------------------ Local $aIconButtons[0] ;Array to manage Buttons Local $aIconBLabels[0] ;Array to manage Buttons Local $iButtonPosLeft = 10 ;Inserting Position X Local $iButtonPosTop = 10 ;Inserting Position Y Local $iButtonCount Local $iIcnPosOffset = 0 Local $iIconCt = _WinAPI_ExtractIconEx("shell32.dll", -1, 0, 0, 0) ;retrieve count of Icons ConsoleWrite("Icons: " & $iIconCt & @CRLF) Local $iIconIdx = 0 ;The Icon Index to begin extracting at Local $tIconsLg = DllStructCreate("HANDLE[" & $iIconCt & "]") Local $pIconsLg = DllStructGetPtr($tIconsLg) Local $tIconsSm = DllStructCreate("HANDLE[" & $iIconCt & "]") Local $pIconsSm = DllStructGetPtr($tIconsSm) $iIconCt = _WinAPI_ExtractIconEx("shell32.dll", $iIconIdx, $pIconsLg, $pIconsSm, $iIconCt) ;Get Large/ Small Icon Handles into arrays ConsoleWrite("Icons Extracted: " & $iIconCt & @CRLF) ; ;; PS Don't Forget _WinAPI_DestroyIcon() For $iButtonCount = 1 To 200 If BitAND($iButtonCount, 1) Then _ArrayAdd($aIconButtons, GUICtrlCreateButton("", $iButtonPosLeft, $iButtonPosTop, 45, 45, $BS_ICON)) ;Icon Only Else _ArrayAdd($aIconButtons, GUICtrlCreateButton($iButtonCount, $iButtonPosLeft, $iButtonPosTop, 45, 45)) ;Icon and Text EndIf _ArrayAdd($aIconBLabels, GUICtrlCreateLabel(1 * ($iButtonCount + $iIcnPosOffset), $iButtonPosLeft, $iButtonPosTop + 45, 45, 15)) GUICtrlSetStyle($aIconBLabels[$iButtonCount - 1], BitOR($SS_CENTER, $SS_CENTERIMAGE)) $iButtonPosLeft = $iButtonPosLeft + 50 If Mod($iButtonCount, 20) = 0 Then $iButtonPosTop = $iButtonPosTop + 70 $iButtonPosLeft = 10 EndIf ;retrieving Icons by positive position ;***************************************************************************************** ;$MessageTemp = GUICtrlSetImage($aIconButtons[$iButtonCount - 1], "shell32.dll", 1 * ($iButtonCount + $iIcnPosOffset) , 1) ;***************************************************************************************** If $iButtonCount < $iIconCt Then If BitAND($iButtonCount, 1) Then GUICtrlSendMsg($aIconButtons[$iButtonCount - 1], $BM_SETIMAGE, $IMAGE_ICON, DllStructGetData($tIconsLg, 1, $iButtonCount)) Else GUICtrlSendMsg($aIconButtons[$iButtonCount - 1], $BM_SETIMAGE, $IMAGE_ICON, DllStructGetData($tIconsSm, 1, $iButtonCount)) EndIf EndIf Next ;Destroy all the extracted icons ConsoleWrite("Destroying Icons" & @CRLF) For $i = 1 To $iIconCt _WinAPI_DestroyIcon(DllStructGetData($tIconsLg, 1, $i)) _WinAPI_DestroyIcon(DllStructGetData($tIconsSm, 1, $i)) Next ;============================================================================================================ ;GUI Loop ;============================================================================================================ While True ;------------------------------------------------------------------------------------------------------------ ;Get GUI-Messages ;------------------------------------------------------------------------------------------------------------ $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then ExitLoop ;------------------------------------------------------------------------------------------------------------ ;Get Traymenu Messages ;------------------------------------------------------------------------------------------------------------ Switch TrayGetMsg() Case $IdTrayMenuExit ;Exit. ExitLoop EndSwitch ;------------------------------------------------------------------------------------------------------------ WEnd EndFunc ;==>Main  
    • odaylton
      By odaylton
      I would like to get a region of the screen but avoiding having to save to a file first.
      I believe it is a lack of knowledge on my part but the GUICtrlSetImage function does not allow you to define an image without being a file.
      How to do this:
      ;.... $Pic3 = GUICtrlCreatePic("", 8, 64, 84, 84, -1, _ $WS_EX_STATICEDGE) ;para ter borda em baixo relevo ;.... _ScreenCapture_Capture(@ScriptDir & "\areatemp.jpg", 10, 10, 200, 200) GUICtrlSetImage($Pic3, @ScriptDir & "\areatemp.jpg") ;....  
    • wakillon
      By wakillon
      Create water effects using waterctrl.dll.
       
      Topic
       

    • Michiel
      By Michiel
      I'm trying to use '?do=embed' frameborder='0' data-embedContent>> but none of the examples work. Mostly, I'm just not seeing any pictures, just nothing, a window with some text but no picture. What am I doing wrong? Do these examples work for anybody else?
    • Shanheavel
      By Shanheavel
      I'd like to load a BMP file then change chosen color (0xFF00FF) to transparent and save it as PNG file. I'm using a code from other thread. I've modified it a little, but it still doesn't work.
      My program displays image with transparent color correctly, however saves a black image file.
      #include <Constants.au3> #include <WinAPIEx.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> Global Const $STM_SETIMAGE = 0x0172 Global Const $STM_GETIMAGE = 0x0173 $hForm = GUICreate('MyGUI', 400, 400) $Pic = GUICtrlCreatePic('', 50, 50, 144, 87) $hPic = GUICtrlGetHandle(-1) _GDIPlus_Startup() $hDstDC = _WinAPI_CreateCompatibleDC(0) $hBitmap = _WinAPI_CreateSolidBitmap(0, _WinAPI_GetSysColor($COLOR_3DFACE), 144, 87, 0) $hDstSv = _WinAPI_SelectObject($hDstDC, $hBitmap) $hSrcDC = _WinAPI_CreateCompatibleDC(0) $hImg = _WinAPI_LoadImage(0, @ScriptDir & '\piclvq.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE) $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hImg) _WinAPI_TransparentBlt($hDstDC, 0, 0, 144, 87, $hSrcDC, 0, 0, 144, 87, 0xFF00FF) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hForm) $hImage = _GDIPlus_BitmapCreateFromGraphics(144, 87, $hGraphic) ; Save resultant image _GDIPlus_ImageSaveToFile($hImage, "My_transparent_image.png") _WinAPI_SelectObject($hDstDC, $hDstSv) _WinAPI_DeleteDC($hDstDC) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hImg) _WinAPI_DeleteObject(_SendMessage($hPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)) $hPic = _SendMessage($hPic, $STM_GETIMAGE) If $hPic <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf GUISetState() Do Until GUIGetMsg() = -3 piclvq.bmp
×