Jump to content
Sign in to follow this  

Show a picture, that has transparency

Recommended Posts


I'm trying to make a software which has a part that shows a picture on your desktop. It has got some transparency too, so I must give a transparent color to the GUI.

Heres the pic: http://noob.hu/2012/06/07/protected.bmp (Black stuff is just a browser-bug)

Here's my current code:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

GUICreate("", 249, 73, 419, 289, $WS_POPUP, $WS_EX_TRANSPARENT)
GUICtrlCreatePic(@ScriptDir & "protected.bmp", 0, 0, 248, 72)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg


When I run it there's a cream-like color around the pic (the default gui color). Any idea why it itsn't transparent? ($WS_EX_TRANSPARENT)

Edited by Unc3nZureD

Share this post

Link to post
Share on other sites

This is a different bmp format which is even not displayed properly in GIMP or XnView. I would suggest to convert it to png.

PNG can be displayed properly even it has transparency using this function:

Func SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI,  $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
EndFunc   ;==>SetTransparentBitmap



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

Okay, I will try, but I can see the pic in gimp perfectly (because I made it). And in AutoIT, that black stuff from behind goes away - I just want to hide the main Gui.



Converted to png - tried an other code - works perfectly ;) Thanks.

Edited by Unc3nZureD

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.