Skip to main content



      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 11:16 Go to next message
Eclipse UserFriend
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 17: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 18:57 Go to previous messageGo to next message
Eclipse UserFriend
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 05:21 Go to previous messageGo to next message
Eclipse UserFriend
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 06: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 10:14 Go to previous messageGo to next message
Eclipse UserFriend
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 11: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 11:54 Go to previous messageGo to next message
Eclipse UserFriend
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 14:04 Go to previous messageGo to next message
Eclipse UserFriend
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 09:53 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 13:46:18 EDT 2025

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

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

Back to the top