Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Transparency in the window title-bar icon
Transparency in the window title-bar icon [message #412526] Sun, 25 January 2004 16:16 Go to next message
Tom Robinson is currently offline Tom RobinsonFriend
Messages: 8
Registered: July 2009
Junior Member
I'm trying to figure out how to have an icon on my window title-bar
with transparent pixels. I've made an icon as a png file, and set the
palette transparency, but for some reason it seems to be ignored when
displayed, and I get a white background for my icon no matter what.

I'm using this code to load and display the icon:

// set the window icon
Image icon = new Image(display, "c:\\project\\icon.png");
shell.setImage(icon);

I tried adding "icon.setBackground(new Color(display, 255, 255,
255));" but it appears to have no effect. Do I have to fiddle around
with the ImageData?
Re: Transparency in the window title-bar icon [message #412529 is a reply to message #412526] Sun, 25 January 2004 22:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: flavien.bach.free.fr

you should use gif images instead of png graphics ... Transparency seems to
work better with gif than with png in swt



"Tom Robinson" <tom@alkali.org> a
Re: Transparency in the window title-bar icon [message #412531 is a reply to message #412529] Sun, 25 January 2004 23:57 Go to previous messageGo to next message
Tom Robinson is currently offline Tom RobinsonFriend
Messages: 8
Registered: July 2009
Junior Member
On Sun, 25 Jan 2004 23:38:53 +0100, "Flavien Bach"
<flavien.bach@free.fr> wrote:

>you should use gif images instead of png graphics ... Transparency seems to
>work better with gif than with png in swt

Thanks for your input .. I tried gif's already and seemed to have
exactly the same problem. Have you managed to get it to work with the
title-bar icons using gifs?
Re: Transparency in the window title-bar icon [message #412536 is a reply to message #412531] Mon, 26 January 2004 10:21 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
I am using SWT ver. 3.0 M6 and it works fine using a transparent GIF.

> On Sun, 25 Jan 2004 23:38:53 +0100, "Flavien Bach"
> <flavien.bach@free.fr> wrote:

> >you should use gif images instead of png graphics ... Transparency seems to
> >work better with gif than with png in swt

> Thanks for your input .. I tried gif's already and seemed to have
> exactly the same problem. Have you managed to get it to work with the
> title-bar icons using gifs?
Re: Transparency in the window title-bar icon [message #412537 is a reply to message #412526] Mon, 26 January 2004 11:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.forritan.net

Tom Robinson wrote:
> I'm trying to figure out how to have an icon on my window title-bar
> with transparent pixels. I've made an icon as a png file, and set the
> palette transparency, but for some reason it seems to be ignored when
> displayed, and I get a white background for my icon no matter what.
>
> I'm using this code to load and display the icon:
>
> // set the window icon

You need to create the Image with a specified transparancymask, so
instead of:
> Image icon = new Image(display, "c:\\project\\icon.png");
write:

Image icon = new Image(display, "c:\\project\\icon.png");
icon = new Image(display, icon, icon.getTransparencyMask());

> shell.setImage(icon);
>
> I tried adding "icon.setBackground(new Color(display, 255, 255,
> 255));" but it appears to have no effect. Do I have to fiddle around
> with the ImageData?
>

Regards,
-eyðun
Re: Transparency in the window title-bar icon [message #412545 is a reply to message #412537] Mon, 26 January 2004 15:14 Go to previous messageGo to next message
Tom Robinson is currently offline Tom RobinsonFriend
Messages: 8
Registered: July 2009
Junior Member
On Mon, 26 Jan 2004 11:43:06 +0000, Eyðun Nielsen
<eclipse-news@forritan.net> wrote:

>You need to create the Image with a specified transparancymask, so
>instead of:
>> Image icon = new Image(display, "c:\\project\\icon.png");
>write:
>
>Image icon = new Image(display, "c:\\project\\icon.png");
>icon = new Image(display, icon, icon.getTransparencyMask());

Thanks, that works except the 2nd constructor for Image expects
ImageData arguments instead of Image, so I had to do:

Image icon = new Image(display, "c:\\project\\icon.gif");
ImageData icondata = icon.getImageData();
icon = new Image(display, icondata, icondata.getTransparencyMask());
shell.setImage(icon);

And that works fine, with the gif rather than the png. Doesn't work
with the png for some reason but that doesn't really bother me.
Re: Transparency in the window title-bar icon [message #412732 is a reply to message #412545] Mon, 26 January 2004 16:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.forritan.net

Tom Robinson wrote:

> On Mon, 26 Jan 2004 11:43:06 +0000, Eyðun Nielsen
> <eclipse-news@forritan.net> wrote:
>
>
>>You need to create the Image with a specified transparancymask, so
>>instead of:
>>
>>>Image icon = new Image(display, "c:\\project\\icon.png");
>>
>>write:
>>
>>Image icon = new Image(display, "c:\\project\\icon.png");
>>icon = new Image(display, icon, icon.getTransparencyMask());
>
>
> Thanks, that works except the 2nd constructor for Image expects
> ImageData arguments instead of Image, so I had to do:
>
> Image icon = new Image(display, "c:\\project\\icon.gif");
> ImageData icondata = icon.getImageData();
> icon = new Image(display, icondata, icondata.getTransparencyMask());
> shell.setImage(icon);
>

Oops, sorry about that... I didn't test it ;-)

> And that works fine, with the gif rather than the png. Doesn't work
> with the png for some reason but that doesn't really bother me.
>

I think that this is because there isn't any default transparent pixel
in png. (or for that matter jpg).

But you can just set the transparent pixel like this (I think that in
gif the default transparent pixel is the pixel in the lower-left corner):

<code>
Image icon= new Image(display, "c:\\project\\icon.png");
ImageData icondata= icon.getImageData();
icondata.transparentPixel= icondata.getPixel(0, icondata.height - 1);
icon= new Image(display, icondata, icondata.getTransparencyMask());
shell.setImage(icon);
</code>

If you do like this then it should work with any format that image supports.

regards,
-eyðun
Re: Transparency in the window title-bar icon [message #412743 is a reply to message #412732] Mon, 26 January 2004 16:54 Go to previous messageGo to next message
Tom Robinson is currently offline Tom RobinsonFriend
Messages: 8
Registered: July 2009
Junior Member
On Mon, 26 Jan 2004 16:43:16 +0000, Eyðun Nielsen
<eclipse-news@forritan.net> wrote:

>I think that this is because there isn't any default transparent pixel
>in png. (or for that matter jpg).
>
>But you can just set the transparent pixel like this (I think that in
>gif the default transparent pixel is the pixel in the lower-left corner):
>
><code>
>Image icon= new Image(display, "c:\\project\\icon.png");
>ImageData icondata= icon.getImageData();
>icondata.transparentPixel= icondata.getPixel(0, icondata.height - 1);
>icon= new Image(display, icondata, icondata.getTransparencyMask());
>shell.setImage(icon);
></code>
>
>If you do like this then it should work with any format that image supports.

Yep, that works too, with gifs etc. Thanks!
Re: Transparency in the window title-bar icon [message #445995 is a reply to message #412743] Mon, 15 November 2004 19:04 Go to previous messageGo to next message
Brian is currently offline BrianFriend
Messages: 34
Registered: July 2009
Member
Tom Robinson wrote:
> On Mon, 26 Jan 2004 16:43:16 +0000, Eyðun Nielsen
> <eclipse-news@forritan.net> wrote:
>
>
>>I think that this is because there isn't any default transparent pixel
>>in png. (or for that matter jpg).
>>
>>But you can just set the transparent pixel like this (I think that in
>>gif the default transparent pixel is the pixel in the lower-left corner):
>>
>><code>
>>Image icon= new Image(display, "c:\\project\\icon.png");
>>ImageData icondata= icon.getImageData();
>>icondata.transparentPixel= icondata.getPixel(0, icondata.height - 1);
>>icon= new Image(display, icondata, icondata.getTransparencyMask());
>>shell.setImage(icon);
>></code>
>>
>>If you do like this then it should work with any format that image supports.
>
>
> Yep, that works too, with gifs etc. Thanks!
>

Hi Guys

I want to do exactly the same thing, Showing an image in the title bar..
My image type is ICO so I wonder would I do the same get image data then
call the constructor with icondata.getTransparencyMask() parameter ?

another question : If I want to convert an ICO image to a BMP or gif
image can I just change the name of the file?

thank you

Brian
Re: Transparency in the window title-bar icon [message #446039 is a reply to message #445995] Tue, 16 November 2004 14:53 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
In order for this to work effectively on Windows, you should continue to use
an icon. This is the only thing that Windows really knows how to display in
the title bar of a shell.

"Brian" <brian.alsaadi@gmail.com> wrote in message
news:4198FDCA.4020708@gmail.com...
> Tom Robinson wrote:
> > On Mon, 26 Jan 2004 16:43:16 +0000, Ey
Previous Topic:plz help:java in eclipse view
Next Topic:How to change the tooltip delay?
Goto Forum:
  


Current Time: Fri Apr 19 11:24:00 GMT 2024

Powered by FUDForum. Page generated in 0.02915 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top