Sign in to follow this  
Followers 0
forever

Transparent pictures ?

27 posts in this topic

#1 ·  Posted (edited)

I tried to make a moving object (picture) in my dialog. But i noticed that the transparent areas (it's a .gif) are in the gui-grey color, ...

how to solve this problem?

I've got one picture (.jpg) as a background (filling whole gui) .. but how to draw objects with transparent areas on this one ?

Could be very useful! especially for moving objects...

thanks in advance

//edit

#include <GUIConstants.au3>
;Run("soma.exe")

GUICreate("Basti back by Popular Demand", 800, 330, -1, -1, "", $WS_EX_LAYERED)
$background = GUICtrlCreatePic ("images\demo-bg.jpg", 0, 0, 800, 300)
$basti_stay = GUICtrlCreatePic ("images\l_st.gif", 770, 220, 14, 80)


GUISetState(@SW_SHOW)


While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Is what i have now, l_st.gif got it's transparent areas filled with rgb 255,0,255 (pink). Now these areas are white, but i want demo-bg.jpg as the background for it, how to realize that?

//EDIT2

My try (look up) didn't work.: with $ws_ex_layered it show me the things behind the window, i just want the picture as a background :lmao:

Here's what i have for now, perhaps anyone got a idea (i want the pink places of the figure beeing transparent)

#include <GUIConstants.au3>

;ISPRESSED?
Func _IsPressed($hexKey)
  Local $aR, $bO
  $hexKey = '0x' & $hexKey
  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
  If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
     $bO = 1
  Else
     $bO = 0
  EndIf
  Return $bO
EndFunc
;ISPRESSED!

;Run("soma.exe")

$bastario = GUICreate("Basti back by Popular Demand", 800, 300, -1, -1)
GUISetBkColor (0xE0FFFF)
$background = GUICtrlCreatePic ("images\demo-bg.jpg", 0, 0, 800, 300)
$basti = GUICtrlCreatePic ("images\l_st.gif", 770, 220, 14, 80)
$basti_Pos = ControlGetPos($bastario, "", $basti) 
GUISetState(@SW_SHOW)


While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    
 ;Moving Left
    if _IsPressed("25") Then
    $basti_Pos[0] = $basti_Pos[0] -5
    GUICtrlSetPos($basti, $basti_Pos[0], $basti_Pos[1])
    EndIf
Wend

Images i used could be downloaded from here

Background

l_st.gif

Edited by Jon

Share this post


Link to post
Share on other sites



I tried to make a moving object (picture) in my dialog. But i noticed that the transparent areas (it's a .gif) are in the gui-grey color, ...

how to solve this problem?

I've got one picture (.jpg) as a background (filling whole gui) .. but how to draw objects with transparent areas on this one ?

Could be very useful! especially for moving objects...

thanks in advance

//edit

#include <GUIConstants.au3>
;Run("soma.exe")

GUICreate("Basti back by Popular Demand", 800, 330, -1, -1, "", $WS_EX_LAYERED)
$background = GUICtrlCreatePic ("images\demo-bg.jpg", 0, 0, 800, 300)
$basti_stay = GUICtrlCreatePic ("images\l_st.gif", 770, 220, 14, 80)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Is what i have now, l_st.gif got it's transparent areas filled with rgb 255,0,255 (pink). Now these areas are white, but i want demo-bg.jpg as the background for it, how to realize that?

//EDIT2

My try (look up) didn't work.: with $ws_ex_layered it show me the things behind the window, i just want the picture as a background :lmao:

Here's what i have for now, perhaps anyone got a idea (i want the pink places of the figure beeing transparent)

#include <GUIConstants.au3>

;ISPRESSED?
Func _IsPressed($hexKey)
  Local $aR, $bO
  $hexKey = '0x' & $hexKey
  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
  If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
     $bO = 1
  Else
     $bO = 0
  EndIf
  Return $bO
EndFunc
;ISPRESSED!

;Run("soma.exe")

$bastario = GUICreate("Basti back by Popular Demand", 800, 300, -1, -1)
GUISetBkColor (0xE0FFFF)
$background = GUICtrlCreatePic ("images\demo-bg.jpg", 0, 0, 800, 300)
$basti = GUICtrlCreatePic ("images\l_st.gif", 770, 220, 14, 80)
$basti_Pos = ControlGetPos($bastario, "", $basti) 
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    
  ;Moving Left
    if _IsPressed("25") Then
    $basti_Pos[0] = $basti_Pos[0] -5
    GUICtrlSetPos($basti, $basti_Pos[0], $basti_Pos[1])
    EndIf
Wend

Images i used could be downloaded from here

Background

l_st.gif

<{POST_SNAPBACK}>

as I design the transparency, the entire GUI will be transparent on the desktop background.

So you need to synchronize in position 2 windows one being your background and the other having the transparent label

I don't know if there is a solution to make what you like in one window o:)

Share this post


Link to post
Share on other sites

as I design the transparency, the entire GUI will be transparent on the desktop background.

So you need to synchronize in position 2 windows one being your background and the other having the transparent label

I don't know if there is a solution to make what you like in one window :lmao:

<{POST_SNAPBACK}>

That seems to be a very bad workaround o:) but I'll give it a try (thanks)... any other idea's ?

Share this post


Link to post
Share on other sites

Wait.. that doesn't seem right. The icon and cursor transparency works perfectly fine. The only problem there is the limited sizes. I don't understand the need to make a whole window transparent..?

Share this post


Link to post
Share on other sites

Wait.. that doesn't seem right. The icon and cursor transparency works perfectly fine. The only problem there is the limited sizes. I don't understand the need to make a whole window transparent..?

<{POST_SNAPBACK}>

the need was express by you (your picture)

it is possible now with the $WS_EX_LAYERED but for the whole window not a pic on pic in the same window.

To be frank the GUI design support badly refresh on overlap controls. Sometime it works but not all the time. :lmao:

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

the need was express by you (your picture)

it is possible now with the $WS_EX_LAYERED but for the whole window not a pic on pic in the same window.

To be frank the GUI design support badly refresh on overlap controls. Sometime it works but not all the time. :lmao:

<{POST_SNAPBACK}>

Wait, so how does this work exactly? I tried creating a window with the $WS_EX_LAYERED style, but it just seems to be completely invisible...

Wait.. scratch that. If I put a picture control in it, it becomes visible, but doesn't appear to be any different from a regular window.

Here's my test code:

#include <GuiConstants.au3>

GuiCreate('Window Title', 200, 100, -1, -1, -1, $WS_EX_LAYERED)

GuiCtrlCreateButton('Button', 0, 0)
GuiCtrlCreateButton('Button 2', 100, 0)

GuiCtrlCreatePic('picture.bmp', 0, 50, 200, 50); <-- If you comment out this line, no GUI window appears at all

GuiSetState()

While 1
    $i_Msg = GuiGetMsg()

    Select
        Case $i_Msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

*Edit: Nevermind! Sorry about that, I figured it out. Any pink (ff00ff) color is transparent. Nifty.

I think what the OP is looking for is just better GIF transparency support. So that a GIF with transparent colours looks like a cursor or icon with transparent background. Is that possible?

Edited by Saunders

Share this post


Link to post
Share on other sites

Wait, so how does this work exactly? I tried creating a window with the $WS_EX_LAYERED style, but it just seems to be completely invisible...

Wait.. scratch that. If I put a picture control in it, it becomes visible, but doesn't appear to be any different from a regular window.

Here's my test code:

#include <GuiConstants.au3>

GuiCreate('Window Title', 200, 100, -1, -1, -1, $WS_EX_LAYERED)

GuiCtrlCreateButton('Button', 0, 0)
GuiCtrlCreateButton('Button 2', 100, 0)

GuiCtrlCreatePic('picture.bmp', 0, 50, 200, 50); <-- If you comment out this line, no GUI window appears at all

GuiSetState()

While 1
    $i_Msg = GuiGetMsg()

    Select
        Case $i_Msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

*Edit: Nevermind! Sorry about that, I figured it out. Any pink (ff00ff) color is transparent. Nifty.

I think what the OP is looking for is just better GIF transparency support. So that a GIF with transparent colours looks like a cursor or icon with transparent background. Is that possible?

<{POST_SNAPBACK}>

The current implemenation allow any transparent color the one in the leftupper pixel.

I understand OP want more but I didn't find a better implementation. :lmao:

Share this post


Link to post
Share on other sites

My problem is not better gif-transparency support, myproblem is just that i can't get the area fileld with FF00FF gets transparent!

If i use ws_ex_layered the are is transparent, yea, but it doesn't shows the picture under it, it shows the thing behind the window! That's my problem, i want the background as a real background.. the background (thepic) should be shown on other transparent areas on pictures which are drawn over this one (over the background)

could i explain it now?

Share this post


Link to post
Share on other sites

My problem is not better gif-transparency support, myproblem is just that i can't get the area fileld with FF00FF gets transparent!

If i use ws_ex_layered the are is transparent, yea, but it doesn't shows the picture under it, it shows the thing behind the window! That's my problem, i want the background as a real background.. the background (thepic) should be shown on other transparent areas on pictures which are drawn over this one (over the background)

could i explain it now?

<{POST_SNAPBACK}>

That's what I want too for my Tetris script/game.

I made parts of the pictures pink (0xff00ff), but the GUI is acting really strange.

Sometimes I see the pink and sometimes I can look through the GUI.

Should I explain in detail what happens with my original script?

Share this post


Link to post
Share on other sites

So we've got the same problem, but how could we solve it, is there absolutely no way then creating a second window and putting it behind the ws_ex_layered window?!?!? Anyone must have a idea, that cannot be :lmao: .. if it is so i think it should be highly recommended that this feature gets implemented ..

Share this post


Link to post
Share on other sites

That's what I want too for my Tetris script/game.

I made parts of the pictures pink (0xff00ff), but the GUI is acting really strange.

Sometimes I see the pink and sometimes I can look through the GUI.

Should I explain in detail what happens with my original script?

<{POST_SNAPBACK}>

Obviously you can explain better post a repro script if you cannot define a small repro script just PM what is needed script+ images

I will try to understand.

Just few info if you use $WS_EX_LAYERED it is normal that a transparent gif will just dispaly the opaque part the transparent part will show the window which is behind.

if you don't use $WS_EX_LAYERED the transparent color of your gif will be display as you defined it. It could be pink if it was the color you define as the transparency color during the gif creation. Remember AutoiT KNOW THE TRANSPARENCY COLOR by looking at the pixel at coord 0,0 of your gif image.

I hope that explain what you are seing :lmao:

Share this post


Link to post
Share on other sites

Very interesting. I will look into this tomorrow.

Share this post


Link to post
Share on other sites

Thanks, but how do i set the transparency color from my gif with photoshop ?

Does anyone know?

Share this post


Link to post
Share on other sites

Thanks, but how do i set the transparency color from my gif with photoshop ?

Does anyone know?

<{POST_SNAPBACK}>

I don't know for Photoshop but you have a freeware at www.irfanview.com very easy when you save in .gif format

Share this post


Link to post
Share on other sites

I don't know for Photoshop but you have a freeware at www.irfanview.com very easy when you save in .gif format

<{POST_SNAPBACK}>

I've IV too .. how to do it? :lmao:

Share this post


Link to post
Share on other sites

I've IV too .. how to do it? :lmao:

<{POST_SNAPBACK}>

You save as a .gif and chooze to select yourself the transparent color.

so the application your picture again and you click inside on the choosen color

Share this post


Link to post
Share on other sites

Hot! Yesterday I was searching my _ss off for some freeware graphics editor.

I'm glad you explained it, jpm.

I'll install it right away.

Share this post


Link to post
Share on other sites

Mhhh, i've done it as you said and in the windows xp thumbnails it shows the pink areas transparent now, but in the au3 gui it shows them pink :lmao: please help..

here some code from me :

~gui.au3

#include <GUIConstants.au3>
#include <File.au3>
#include "function.inc.au3"
#include "images.au3"

$bastario = GUICreate("Basti back by Popular Demand", 800, 300, -1, -1)
$background = GUICtrlCreatePic ($img_DemoBg, 0, 0, 800, 300)
$basti = GUICtrlCreatePic ($img_L_st, 770, 220, 15, 80)

$basti_Pos = ControlGetPos($bastario, "", $basti) 

GUISetState(@SW_SHOW)
...(cut off)...

~images.au3

$Img_DemoBg = _TempFile()
FileInstall ("images/demo-bg.jpg", $Img_Demobg)
$Img_Blank = _TempFile()
FileInstall ("images/blank.gif", $Img_Blank)
$Img_L_wl = _TempFile()
FileInstall ("images/l_wl.gif", $Img_L_wl)
$Img_L_st = _TempFile()
FileInstall ("images/l_st2.gif", $Img_L_st);;THIS FILE MUST SHOW UP TRANSPARENT (PINK AREAS) but it doenst do :(
$Img_R_wl = _TempFile()
FileInstall ("images/r_wl.gif", $Img_R_wl)
$Img_R_st = _TempFile()
FileInstall ("images/r_st.gif", $Img_R_st)

Share this post


Link to post
Share on other sites

Mhhh, i've done it as you said and in the windows xp thumbnails it shows the pink areas transparent now, but in the au3 gui it shows them pink :lmao: please help..

here some code from me :

~gui.au3

#include <GUIConstants.au3>
#include <File.au3>
#include "function.inc.au3"
#include "images.au3"

$bastario = GUICreate("Basti back by Popular Demand", 800, 300, -1, -1)
$background = GUICtrlCreatePic ($img_DemoBg, 0, 0, 800, 300)
$basti = GUICtrlCreatePic ($img_L_st, 770, 220, 15, 80)

$basti_Pos = ControlGetPos($bastario, "", $basti) 

GUISetState(@SW_SHOW)
...(cut off)...

~images.au3

$Img_DemoBg = _TempFile()
FileInstall ("images/demo-bg.jpg", $Img_Demobg)
$Img_Blank = _TempFile()
FileInstall ("images/blank.gif", $Img_Blank)
$Img_L_wl = _TempFile()
FileInstall ("images/l_wl.gif", $Img_L_wl)
$Img_L_st = _TempFile()
FileInstall ("images/l_st2.gif", $Img_L_st);;THIS FILE MUST SHOW UP TRANSPARENT (PINK AREAS) but it doenst do :(
$Img_R_wl = _TempFile()
FileInstall ("images/r_wl.gif", $Img_R_wl)
$Img_R_st = _TempFile()
FileInstall ("images/r_st.gif", $Img_R_st)

<{POST_SNAPBACK}>

use the attached files I think you will understand

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

It works here! Y'know how happy I am?

I'll explain what I did.

- Install IrfanView from http://www.irfanview.com

- Start the app

- File, Batch Conversion

- Select all BMP files from the previous time

- drag them to the left listbox

- Click "Use this directory as output"

- "Work as: Batch Conversion"

- "Output format: GIF"

- Check "Use advanced options"

- Click "Set advanced options"

- check "Don't enlarge smaller files"

- check "CHANGE COLOR DEPTH"

- choose 256 colors (8 BPP)

- Click on "Options"

- check "Save interlaced"

- check "Save transparent color"

- choose "Choose transparant color during saving"

- Press OK

- Click Start

- Choose white as the transparency color, for every file

- Open my script in an editor

- Replace .BMP to .GIF

- Save

Result: The MyTetris objects don't overlap each other any more.

Edited by SlimShady

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  
Followers 0