Jump to content

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


Recommended Posts

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

Link to comment
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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

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

Link to comment
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! :)

Link to comment
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

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

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
Link to comment
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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
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
 Share

×
×
  • Create New...