Sign in to follow this  
Followers 0
BrendonKoz

Possible bug within GUICtrlCreatePic() and/or GuiSetBkColor() causing pixelated transparency?

8 posts in this topic

My originaly script where I was noticing this issue was quite long, so I trimmed it down considerably (93 lines to 5) to show the example issue. From what I've noticed in related topics, it's never really been solved (at least from my searches), and it unfortunately seems to not show up on all machines.

Description: It seems that when using GUICtrlCreatePic() alongside GuiSetBkColor() the embedded image will get transparent artifacts. It seems as though it's light colors only - as to what colors/shades, I cannot say.

Other topics:

March 2012: --

April 2010 --

July 2012 -- (not actually solved)

March 2005 --

Hopefully this has been solved and my searching is just lacking...

; Window
$kiosk = GUICreate("", @DesktopWidth, @DesktopHeight)
GuiSetBkColor("0x000000")
; Background image
GUICtrlCreatePic("image.jpg", 0, 0, 640, 480)


; --- Display the Coded Form --- ;
GUISetState(@SW_SHOW)
Sleep(2000)

Example image file used is attached, as well as a screenshot of the window as rendered on my machine (Win7 Pro x64). To be fair I'm currently running v3.3.6.1. After I post this I'll upgrade and check the current version to see if it fixes the problem(s).

The "transparent_pixelation.jpg" file shows a line through the example input image. Around the "white" circle of the image there are also areas of black pixels that don't exist in the original.

I'm not too familiar with using image or form functions in AutoIt (I primarily use it to automate actions) so if anyone has any ideas I'm willing to give it a shot.

post-32577-0-94819500-1365452924_thumb.j

post-32577-0-00080900-1365453004_thumb.j

Share this post


Link to post
Share on other sites

Update: The upgrade to version 3.3.8.1 did not seem to help.

Share this post


Link to post
Share on other sites

I don't know why there is an issue with GUICtrlCreatePic() but there are workarounds to fix it using GDI+.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Tested your script with your images, i don't have that issue ( Xp x86 ):

Posted Image

Anyway:

If a picture is set as a background picture, as the other controls will overlap, it's important to disable the pic control and create it after the others controls: GuiCtrlSetState(-1,$GUI_DISABLE)

Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

As for the background picture - I am using it as a background picture in my primary script that I hit this snag in, but I have also made sure to use the GuiCtrlSetState(-1, $GUI_DISABLE) line as well.

Unfortunately the image that I uploaded showing the issue is run from the exact code shared here.

I'd think that maybe it's an issue with the x64 build of AutoIt (which I am running) but that probably wouldn't explain the issue someone else had from 2005 (unless they were running WinXP x64). I'm also running my primary script with the #AutoIt3Wrapper_UseX64=n declaration, so I would think it would run through the x86 version of AutoIt's compiler.

As for the GDI+ options, are the fixes simply to use it, or are there specific things I should be looking for?

Thank you for the replies thus far! :)

Share this post


Link to post
Share on other sites

Yes, it is simple:

#include <GDIPlus.au3>
_GDIPlus_Startup()
Global $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\image.jpg") ;load bitmap as GDI+ bitmap
Global $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;convert it to a GDI bitmap
_GDIPlus_BitmapDispose($hBitmap)

Global Const $STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0
$kiosk = GUICreate("", @DesktopWidth, @DesktopHeight)
GuiSetBkColor("0x000000")
; Background image
Global $iPic = GUICtrlCreatePic("", 0, 0, 640, 480)
Global $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBITMAP) ;copy GDI bitmap to picture control
If $hB Then _WinAPI_DeleteObject($hB)
; --- Display the Coded Form --- ;
GUISetState(@SW_SHOW)
Sleep(4000)

_WinAPI_DeleteObject($hHBitmap) ;release bitmap
_GDIPlus_Shutdown()
GUIDelete()
Exit

Br,

UEZ

1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

That definitely solves the problem that the standard code I was using had been displaying!

Thank you very much, UEZ (and OliverA too!). Hopefully others will find this topic in the future to solve their issues as well.

Just out of curiosity, since I know you're quite well-versed in AutoIt... Is there any particular reason you explicitly use Exit at the end of your AutoIt scripts since the script would normally exit on its own anyway? Basically - is there any added benefit?

Thank you again! :D

Edited by BrendonKoz

Share this post


Link to post
Share on other sites

In this case it doesn't matter. In some other case it makes sense to use Exit, e.g. when you quit the script somewhere in between.

I'm using Exit automatically regardless whether it is needed or not.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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  
Followers 0

  • Similar Content

    • TheAutomator
      By TheAutomator
      Hi!

      I'm trying to script an ellipse drawing algorithm in AutoIT for learning purposes.
      I use an edit control to "draw" the ellipse with characters.
      The code i have works kinda good but i would like to see if others around here know a better algorithm to do it..
      I would like to be able to give the x, y and width, height arguments to the function and not have to start at the middle point and draw the ellipse around it.

      side note, the ellipse glitches when it has to be 2 pixels high too..
       
      func ellipsePlotPoints ($xc,$yc, $x,$y) pixel ($xc + $x, $yc + $y) pixel ($xc - $x, $yc + $y) pixel ($xc + $x, $yc - $y) pixel ($xc - $x, $yc - $y) endfunc func ellipse($xc,$yc, $a,$b) local $a2 = $a * $a local $b2 = $b * $b local $twoa2 = 2 * $a2 local $twob2 = 2 * $b2 local $p local $x = 0 local $y = $b local $px = 0 local $py = $twoa2 * $y ; Plot the initial point in each quadrant. ellipsePlotPoints ($xc,$yc, $x,$y) ; Region 1 $p = int($b2 - ($a2 * $b) + (0.25 * $a2)) while ($px < $py) $x+=1 $px += $twob2 if ($p < 0) then $p += $b2 + $px else $y-=1 $py -= $twoa2 $p += $b2 + $px - $py endif ellipsePlotPoints ($xc,$yc, $x,$y) wend ; Region 2 $p = int ($b2 * ($x+0.5) * ($x+0.5) + $a2 * ($y-1) * ($y-1) - $a2 * $b2) while ($y > 0) $y-=1 $py -= $twoa2 if ($p > 0) then $p += $a2 - $py else $x+=1 $px += $twob2 $p += $a2 - $py + $px endif ellipsePlotPoints ($xc,$yc, $x,$y) wend endfunc  
    • Byte11
      By Byte11
      WinSetState ("[CLASS:OpusApp]", "", @SW_SHOWMAXIMIZED) and WinSetState ("[CLASS:OpusApp]", "", @SW_MAXIMIZE) don't maximize the window.  Using WinSetState("[CLASS:OpusApp]","",@SW_RESTORE) allows me to maximize it about 15% of the time. I've tried using  WinMove("[active]",0,0,@Desktopwidth,@Desktopheight), but that only makes it worse. I've also tried putting in a sleep and maximizing it again. Does anyone have a solution?
      Here's my code:
      The startup script is intentionally commented, because I'm not testing it right now. The other comment is just for debugging when I need it. 
       
      UPDATE: When I run two instances of the program, it works almost all the time, but if I copy the code inside the else statement twice it doesn't work at all (despite the fact that it's running the same code just in one program vs two). I also noticed that when I run two instances of it, about 50% of the time when it opens both the windows, it also hits the windows button and types the letter d into the search box. Neither of these actions are in my code. I'm not really sure what's going on. 
    • Skeletor
      By Skeletor
      Hi All,
      I know many newbies search for this feature.
      I decided to share this piece of code with everyone.
      Basically its a "splash screen" that has a transparent image.
      In a nutshell - Gui with a transparent gif.
      Enjoy...
      Download attachment....
       
      Splash Screen GUI.zip
    • distancesprinter
      By distancesprinter
      _ArrayDisplay($aArray, "Window Title", "1:", 0, Default, "Column") ; Expected results are rows 1 to the end of the array, all columns. The result is rows 0-1, all columns. The API reference is here:
      https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayDisplay.htm
       
      Am I doing something wrong?
    • Skysnake
      By Skysnake
      Hello
      So I thought it would be cool to use my Gravatar account to display my gravatar in a local GUI.
      I use this code:
      #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: Skysnake Script Function: Example to download avatar from Gravatar and display locally #ce ---------------------------------------------------------------------------- ; Script Start ; includes #include <Crypt.au3> #include <InetConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ; declare Global vars Global $md5GraMail = '' ; will store email for Grvatar request request GravatarLogin() GetAvatar() Func GravatarLogin() ; get the email required for downloading the Gravatar Local $sGraMail = InputBox("Get Gravatar", "What is your email registered with Gravatar?", "someone@somewhere.com", "", -1, -1, 0, 0) ; from http://en.gravatar.com/site/implement/hash/ ; make the hash ; Local $dHash = _Crypt_HashData(GUICtrlRead($g_idInputEdit), $g_iAlgorithm) ; Create a hash of the text entered $md5GraMail = _Crypt_HashData(StringLower(StringStripWS($sGraMail, 8)), $CALG_MD5) ; lose the left two '0x' chars and convert to lower case $md5GraMail = StringLower(StringTrimLeft($md5GraMail, 2)) ; Display the result. MsgBox($MB_SYSTEMMODAL, "", $sGraMail & @CRLF & "md5 " & $md5GraMail, 15) EndFunc ;==>GravatarLogin ; example from Help file: /html/functions/InetGet.htm ; Download a file in the background. ; Wait for the download to complete. Func GetAvatar() ; Save the downloaded file to the temporary folder. Local $sFilePath = _WinAPI_GetTempFileName(@TempDir) ; from http://en.gravatar.com/site/implement/images/ ; <img src="https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50" /> ; Download the file in the background with the selected option of 'force a reload from the remote site.' ; the next THREE options are alternatives ; Gravatar sample from here http://en.gravatar.com/site/implement/images/ ; 1 ;Local $hDownload = InetGet("https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) ; the normal code, should show user avatar ; 2 Local $hDownload = InetGet("https://www.gravatar.com/avatar/" & $md5GraMail & "?d=retro", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) ; my email hardcoded, downloads, but does not show avatar ; 3 ;Local $hDownload = InetGet("https://www.gravatar.com/avatar/cac637b47c9fecc8aa1dcdf71e7a4cc8", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True. Do Sleep(250) Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) ; Retrieve the number of total bytes received and the filesize. Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD) Local $iFileSize = FileGetSize($sFilePath) ; Close the handle returned by InetGet. InetClose($hDownload) ; Display details about the total number of bytes read and the filesize. MsgBox($MB_SYSTEMMODAL, "", "The total download size: " & $iBytesSize & @CRLF & _ "The total filesize: " & $iFileSize, 1) Local $MyGravatar = @ScriptDir & "\Gravatar.jpg" FileCopy($sFilePath, $MyGravatar) MsgBox(0, "Now showing!", $MyGravatar, 5) ; make gui and show file GUICreate("My Gravatar in a GUI " & $MyGravatar, 350, 300, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) ; will create a dialog box that when displayed is centered Local $idPic = GUICtrlCreatePic($MyGravatar, 50, 50, 80, 80) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;FileDelete($MyGravatar) ; Delete the file. FileDelete($sFilePath) EndFunc ;==>GetAvatar Now, here is the issue.
      If I use the example from the Gravatar site, located here:
      http://en.gravatar.com/site/implement/images/
      Then this code  205e460b479e2e5b48aec07710c08d50  downloads this pic   (not me)
      AND it displays correctly.
       
      PROBLEM
      However, If I download my own Gravatar, I see the image in the @Script folder, BUT IT DOES NOT DISPLAY.  The same with the retro image.  To be clear, this image   downloads, but is not displayed.
       
      I guess it has something to do with the format of my gravatar. Or that the display funtion GUICtrlCreatePic() does not like my gravatar.
      I would be grateful if someone would be willing to test this and may offer a suggestion or two... 
      Skysnake