Jump to content
Sign in to follow this  

GUI background color and transparent JPG

Recommended Posts


Simple GUI window. Trying to change background color to black. Using one the three metods, one at a time of course:

- GUISetBkColor(0x000000)

- $hDC = _WinAPI_GetDC($gui)

_WinAPI_SetBkColor($hDC, 0x000000)

- $label = GUICtrlCreateLabel("", 0,0, @DesktopWidth, @DesktopHeight)

GUICtrlSetBkColor($label, 0x000000)

The add JPG over the whole thing: $pic1 = GUICtrlCreatePic($img1, @DesktopWidth/2 - $wi/2, @DesktopHeight/2 - $he/2, 0, 0)

The problem is the JPG has transparent pixels and I don't want that.

Take a look at attached code and image.

JPG image is a simple ordinary JPG.

I have tried different color instead of black, same thing happends.

#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <image_get_info.au3>

Opt("GUICoordMode", 1)

$img1 = "Image1.jpg"

$gui = GUICreate("Slideshow", @DesktopWidth, @DesktopHeight, -1, -1 ,  BitOr($WS_POPUPWINDOW, $WS_MAXIMIZE)) ; I have tried simple GUI, without style, nothing changed
; comment two methods and leave one running
GUISetBkColor(0x000000) ; first method

$hDC = _WinAPI_GetDC($gui)
_WinAPI_SetBkColor($hDC, 0x000000) ; second method

$label = GUICtrlCreateLabel("", 0,0, @DesktopWidth, @DesktopHeight)
GUICtrlSetBkColor($label, 0x000000) ; third method

$wi = _ImageGetParam(_ImageGetInfo($img1), "Width")
$he = _ImageGetParam(_ImageGetInfo($img1), "Height")

$pic1 = GUICtrlCreatePic($img1, @DesktopWidth/2 - $wi/2, @DesktopHeight/2 - $he/2, 0, 0)

GUISetState(@SW_SHOW, $gui)

$msg = GUIGetMsg()

    Switch $Msg
        Case $GUI_EVENT_CLOSE
;~             _WinAPI_ReleaseDC($gui, $hDC)
Until $msg = $GUI_EVENT_CLOSE


Share this post

Link to post
Share on other sites

I figured it out !!

I have Windows 7, also tested on another computer with WIndows 7 - it shows black pixels.

On Windows XP (also two tests: real machine and VMWare) it shows no black pixels !!

But, how do I get around it ???

Will try and use Win API to display image, will let you know how it goes.

Edited by queensoft

Share this post

Link to post
Share on other sites

I get exactly the same issue on Windows 7.

Did you find a workaround or fix?

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