Jump to content

Transparent Background picture


Recommended Posts

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

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

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.

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

  • 6 years later...

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

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

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • 8 years later...
On 4/5/2014 at 9:32 AM, Melba23 said:

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

til today there is no solution to this problem! thats a basic function. autoit su--s

Link to comment
Share on other sites

  • Developers
1 hour ago, ihatejavascript97 said:

til today there is no solution to this problem! thats a basic function. autoit su--s

Sure...  Please go somewhere else moaning instead of necro posting in old threads. 

.. and think before you reply or post again in our forums as the next post like this gets your ass banned. ;)

Edited by Jos
Typo

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...