Sign in to follow this  
Followers 0
huskies

GUI to take the shape of Jpeg?

14 posts in this topic

I noticed that some of the programs that I used can have their GUI take the shape of their background. for example, windows media player, when used with a skin can look like different shapes depending on the background.

How do i for example create a GUI with a heart shape?

Posted Image

and then maybe I will place my buttons on the heart.


<It Shall Be Done>

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I noticed that some of the programs that I used can have their GUI take the shape of their background. for example, windows media player, when used with a skin can look like different shapes depending on the background.

How do i for example create a GUI with a heart shape?

and then maybe I will place my buttons on the heart.

If you can save the image as a 24bit bitmap then you can do this

#include <windowsconstants.au3>
 
 GUICreate("",300,300,300,300,$WS_POPUP,$WS_EX_LAYERED)
 GUISetBkColor(0xffffff);<----------- set the background colour of the window to be the same as the background colour of the heart.
 GUICtrlCreatePic("heart.bmp",0,0,300,279)
 GUISetState()
 
 sleep(3000)

EDIT: Added comment about the GuiSetBkColor

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

If you can save the image as a 24bit bitmap then you can do this

#include <windowsconstants.au3>
 
 GUICreate("",300,300,300,300,$WS_POPUP,$WS_EX_LAYERED)
 GUISetBkColor(0xffffff);<----------- set the background colour of the window to be the same as the background colour of the heart.
 GUICtrlCreatePic("heart.bmp",0,0,300,279)
 GUISetState()
 
 sleep(3000)

EDIT: Added comment about the GuiSetBkColor

thanks I tried your code

and here is the result, do you know how to change it so that the white background of the heart would be transparent? or is that something I will have to fix in photoshop?

Posted Image


<It Shall Be Done>

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

It works with a bitmap, too, like in martin's example.

#include <windowsconstants.au3>

GUICreate("",300,300,300,300,$WS_POPUP,$WS_EX_LAYERED)
GUISetBkColor(0xFF00FF);<----------- set the background colour of the window to be the same as the background colour of the heart.
GUICtrlCreatePic(@MyDocumentsDir & "\Eigene Bilder\test.bmp",0,0,300,279)
GUISetState()

sleep(3000)

(background of bmp is 0xFF00FF )

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It works with a bitmap, too, like in martin's example.

#include <windowsconstants.au3>

GUICreate("",300,300,300,300,$WS_POPUP,$WS_EX_LAYERED)
GUISetBkColor(0xFF00FF);<----------- set the background colour of the window to be the same as the background colour of the heart.
GUICtrlCreatePic(@MyDocumentsDir & "\Eigene Bilder\test.bmp",0,0,300,279)
GUISetState()

sleep(3000)

(background of bmp is 0xFF00FF )

what i meant is that because my heart.bmp has a white background, the gui always has a white background (see image of my example on desktop)

@weaponx

thanks for the link seems like a great idea, i just need to spend some time to learn to customize it

also this is probably goig out on a stretch here, but what if I wanted to use an animated gif as the background?

such as this one

http://e.deviantart.com/emoticons/r/raincloud.gif

will autoit be able to cope?

Edited by huskies

<It Shall Be Done>

Share this post


Link to post
Share on other sites

what i meant is that because my heart.bmp has a white background, the gui always has a white background (see image of my example on desktop)

The image you showed means that you can't have done what I indicated in my post. Or, instead of setting the background colour of the gui set its size to be the same as the bitmap.

#include <windowsconstants.au3>
 
 $gui = GUICreate("",300,279,300,300,$WS_POPUP,$WS_EX_LAYERED)
 
 GUICtrlCreatePic("heart.bmp",0,0,300,279)
 GUISetState()
 
 sleep(3000)

Use this image.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

The image you showed means that you can't have done what I indicated in my post. Or, instead of setting the background colour of the gui set its size to be the same as the bitmap.

#include <windowsconstants.au3>
 
 $gui = GUICreate("",300,279,300,300,$WS_POPUP,$WS_EX_LAYERED)
 
 GUICtrlCreatePic("heart.bmp",0,0,300,279)
 GUISetState()
 
 sleep(3000)

Use this image.

thanks it worked! did you use irfan view or photoshop to crop out the white? when i saved the bmp it looked the same as the bmp i had before, but when i ran the code it worked perfectly

P.S. I did save it as 24 bit bmp when i tried it at first with MS paint

Edited by huskies

<It Shall Be Done>

Share this post


Link to post
Share on other sites

thanks it worked! did you use irfan view or photoshop to crop out the white? when i saved the bmp it looked the same as the bmp i had before, but when i ran the code it worked perfectly

P.S. I did save it as 24 bit bmp when i tried it at first with MS paint

I used MS Paint as well. The only thing I did which might have made a difference is that I flood-filled the borders with white just to be sure they were all the same colour. The actual colour doesn't matter as long as that colour doesn't appear in the image or you will get holes where you don't want them.

When you have a bitmap on a layered window the top left pixel of the last bitmap created is used as the transparent colour. That is why you either have to have the background of the window the same colour as the image background or you must have the whole of the wndow covered by the image.

You can also set the transparent colour with an API call. Prog@ndy has a nice little function for it somewhere in the forums which I've often used. Search for _API_SetLayeredWindowAttributes.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I used MS Paint as well. The only thing I did which might have made a difference is that I flood-filled the borders with white just to be sure they were all the same colour. The actual colour doesn't matter as long as that colour doesn't appear in the image or you will get holes where you don't want them.

When you have a bitmap on a layered window the top left pixel of the last bitmap created is used as the transparent colour. That is why you either have to have the background of the window the same colour as the image background or you must have the whole of the wndow covered by the image.

You can also set the transparent colour with an API call. Prog@ndy has a nice little function for it somewhere in the forums which I've often used. Search for _API_SetLayeredWindowAttributes.

Now I get it, why it is transparent.

I tried using a different bmp and i'm getting a white border on the bottom, so I thought maybe that it is not making the GUI according to the size of the picture, so i added some extra code that retrieves the size of the picture but it didn't fix the problem either.

#include <windowsconstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <GDIPlus.au3>; this is where the magic happens, people

$pngSrc = @ScriptDir & "\DarkArchon.bmp"
$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)

$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)


;GUICreate("",300,300,300,300,$WS_POPUP,$WS_EX_LAYERED)
GUICreate("",$width,$height,300,300,$WS_POPUP,$WS_EX_LAYERED)
GUICtrlCreatePic($pngSrc,0,0,300,279)
;GUICtrlCreatePic($pngSrc,"","",$width,$height)
GUISetBkColor(0xffffff);<----------- set the background colour of the window to be the same as the background colour of the heart.
GUISetState()

sleep(40000)

Posted Image

the picture I used

Posted Image

This is the link where I got the idea of using GDIPlus.au3 to get the dimensions of the picture

http://www.autoitscript.com/forum/index.ph...hl=transparency


<It Shall Be Done>

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Now I get it, why it is transparent.

I tried using a different bmp and i'm getting a white border on the bottom, so I thought maybe that it is not making the GUI according to the size of the picture, so i added some extra code that retrieves the size of the picture but it didn't fix the problem either.

#include <windowsconstants.au3>
  #include <GUIConstantsEx.au3>
  #include <WindowsConstants.au3>
  #include <Date.au3>
  #include <GDIPlus.au3>; this is where the magic happens, people
  
  $pngSrc = @ScriptDir & "\DarkArchon.bmp"
  $hImage = _GDIPlus_ImageLoadFromFile($pngSrc)
  
  $width = _GDIPlus_ImageGetWidth($hImage)
  $height = _GDIPlus_ImageGetHeight($hImage)
  
  
;GUICreate("",300,300,300,300,$WS_POPUP,$WS_EX_LAYERED)
  GUICreate("",$width,$height,300,300,$WS_POPUP,$WS_EX_LAYERED)
  GUICtrlCreatePic($pngSrc,0,0,300,279)
;GUICtrlCreatePic($pngSrc,"","",$width,$height)
  GUISetBkColor(0xffffff);<----------- set the background colour of the window to be the same as the background colour of the heart.
  GUISetState()
  
  sleep(40000)
Good idea, though if you had set the gui background colour to 0 before you created the pic then the size of the gui wouldn't have mattered.

EDIT: I'm a bit worried abot the size of your thighs though, I think you need to spend more time eating junk food and less time on scripting.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Good idea, though if you had set the gui background colour to 0 before you created the pic then the size of the gui wouldn't have mattered.

EDIT: I'm a bit worried abot the size of your thighs though, I think you need to spend more time eating junk food and less time on scripting.

you are right I was over complicating stuff

#include <windowsconstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <GDIPlus.au3>; this is where the magic happens, people

$pngSrc = @ScriptDir & "\DarkArchon.bmp"
;$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)

;$width = _GDIPlus_ImageGetWidth($hImage)
;$height = _GDIPlus_ImageGetHeight($hImage)

$gui = GUICreate("",300,279,300,300,$WS_POPUP,$WS_EX_LAYERED)

GUICtrlCreatePic($pngSrc,0,0,300,279)
GUISetState()

sleep(3000)

and you being worried about me, are you referencing to the jpeg? lol

and LAST Question, I hope :P How do i make it so that the GUI will be dragable , right now I cannot move it anywhere

the picture I want to eventually use

Posted Image

Edited by huskies

<It Shall Be Done>

Share this post


Link to post
Share on other sites

you are right I was over complicating stuff

#include <windowsconstants.au3>
 #include <GUIConstantsEx.au3>
 #include <WindowsConstants.au3>
 #include <Date.au3>
 #include <GDIPlus.au3>; this is where the magic happens, people
 
 $pngSrc = @ScriptDir & "\DarkArchon.bmp"
;$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)
 
;$width = _GDIPlus_ImageGetWidth($hImage)
;$height = _GDIPlus_ImageGetHeight($hImage)
 
 $gui = GUICreate("",300,279,300,300,$WS_POPUP,$WS_EX_LAYERED)
 
 GUICtrlCreatePic($pngSrc,0,0,300,279)
 GUISetState()
 
 sleep(3000)

and you being worried about me, are you referencing to the jpeg? lol

and LAST Question, I hope :P How do i make it so that the GUI will be dragable , right now I cannot move it anywhere

the picture I want to eventually use

To make the gui draggable by the pic you just need to add the extended style Function GUICtrlCreatePic$GUI_WS_EX_PARENTDRAG, but really you should read the help for GuiCtrlCreatePic.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

you are right, I should have read the file on that, anyways yay and thanks for the help!


<It Shall Be Done>

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