Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Transparency in the window title-bar icon
| | | |
Re: Transparency in the window title-bar icon [message #412537 is a reply to message #412526] |
Mon, 26 January 2004 11:43 |
Eclipse User |
|
|
|
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 |
Tom Robinson 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 |
Eclipse User |
|
|
|
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 #445995 is a reply to message #412743] |
Mon, 15 November 2004 19:04 |
Brian 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
|
|
| |
Goto Forum:
Current Time: Mon Sep 23 19:47:20 GMT 2024
Powered by FUDForum. Page generated in 0.04493 seconds
|