Jump to content
Sign in to follow this  
Dieuz

Transparent Background picture

Recommended Posts

Dieuz

Here's my problem: I edited a .gif picture to make a transparent background (with photoshop). When I try to add this picutre into my gui, it make the background of my picture White! I dont want any background on my picture. I just want the red circle alone with nothing around it. How can I set the background of my picture transparent (so the background will have the same color as the gui background)?

SEE ATTACHED FILE

As you can see the picture have an transparent background but when I add it into my gui, it doesnt look transparent

Posted Image

#include <GuiConstants.au3>

GuiCreate("Picture", 200, 250,-1, -1 )

$picture = GuiCtrlCreatePic(@ScriptDir & "\Images\bille1.gif", 100,185,0,0)
GUICtrlSetBkColor($picture, $GUI_BKCOLOR_TRANSPARENT)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else

    EndSelect
WEnd
Exit

Transparent_Background.rar

Edited by Dieuz

Share this post


Link to post
Share on other sites
Dieuz

That doesnt work :) If I use $WS_EX_LAYERED, it make the background of my picture invisible and I can see through the window and I dont want that. I just want to see the background of my gui window.

Edited by Dieuz

Share this post


Link to post
Share on other sites
Dieuz

Helpfile - GUICtrlCreatePic()

I tried this EXACTLY and the background of my picture become invisible and I can see through the windows. I dont want to be able to see through the window I just want the white to disseapear. Try it by yourself with the code I have you.

Share this post


Link to post
Share on other sites
lod3n

This works. Mostly copied from the help file. The help file example illustrates two GUIs.

#include <GUIConstants.au3>

$gui=GUICreate("test transparentpic", 200, 250)
$pic=GUICreate("", 200, 250, 0, 0,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui)
GUICtrlCreatePic(@ScriptDir & "\bille1.gif", 100,185,0,0)

GUISetState(@SW_SHOW,$pic)
GUISetState(@SW_SHOW,$gui)

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else

    EndSelect
WEnd
Exit
A tip about the help file: take the example and modify it bit by bit until it suits your needs. When your changes break it, undo and find out why. The opposite is copying and pasting the one line you think you need, and they copying and pasting more when it doesn't work - I think that's much harder.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites
Dieuz

Yep that work fine If I have only 1 picture but in my Gui I have multiples picture and when I use $WS_EX_LAYERED, every white colors on my pictures become transparent but I just want this setting for 1 picture. The $WS_EX_LAYERED is applied to all the window but how can I set it for only one picture?

Share this post


Link to post
Share on other sites
Zedna

Yep that work fine If I have only 1 picture but in my Gui I have multiples picture and when I use $WS_EX_LAYERED, every white colors on my pictures become transparent but I just want this setting for 1 picture. The $WS_EX_LAYERED is applied to all the window but how can I set it for only one picture?

Make your LAYERED inner GUI window with size of your picture (instead of size main GUI window)

Share this post


Link to post
Share on other sites
MasonMill

I was wanting to do the same thing the OP wants but i want to also make it transparent. Why does it not work when I put in the $WS_EX_TRANSPARENT like below?

#include <GUIConstants.au3>

$gui=GUICreate("test transparentpic", 200, 250)
$pic=GUICreate("", 200, 250, 0, 0,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD,$WS_EX_TRANSPARENT),$gui)
GUICtrlCreatePic(@ScriptDir & "\bille1.gif",100,185,0,0)
WinSetTrans ( $pic, "", 50 )

GUISetState(@SW_SHOW,$pic)
Sleep(1e9)
GUISetState(@SW_SHOW,$gui)

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else

    EndSelect
WEnd
Exit

Are you able to make it transparent and without the white background together?

Thanks,

Mason

Edited by MasonMill

Share this post


Link to post
Share on other sites
UEZ

Try this:
 

#include <GUIConstants.au3>
#include <GDIPlus.au3>
Global Const $STM_SETIMAGE = 0x0172
_GDIPlus_Startup()
$himg=_GDIPlus_ImageLoadFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif")
$hbmp=_GDIPlus_BitmapCreateHBITMAPFromBitmap($himg)
_GDIPlus_ImageDispose($himg)
$gui=GUICreate("test transparentpic", 200, 250)
$pic=GUICtrlCreatePic("",60,85,68,71)
_WinAPI_DeleteObject(GUICtrlSendMsg($pic,$STM_SETIMAGE,$IMAGE_BITMAP,$hbmp))
GUISetState(@SW_SHOW,$gui)

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            _WinAPI_DeleteObject($hbmp)
            _GDIPlus_Shutdown()
        ExitLoop
    EndSelect
WEnd
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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
Melba23

MasonMill,

This thread is nearly 7 years old - please do not necro-post this far back again. We do not encourage it because AutoIt has changed enormously since then and it is very unlikely the problem and/or code are still relevant today. We much prefer that you start a new thread and link to the old one if necessary. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×