Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT 4.25 ToolBar ToolItem icon image wrong transparent color
SWT 4.25 ToolBar ToolItem icon image wrong transparent color [message #1854944] Mon, 19 September 2022 23:45 Go to next message
Martin J is currently offline Martin JFriend
Messages: 50
Registered: August 2015
Member
I found that SWT version 4.25 has a bug but bug report is disabled,

ToolBar toolbar = new ToolBar(p, SWT.NONE);
ToolItem toolitem = new ToolItem(toolbar, SWT.NONE);
toolitem.setImage(image);

Created toolitem image has transparent color. But transparent color is now white as shown in the attached image. This must match background color gray.

This does not happen in 4.24. Icon images in other types of widgets are OK. Only with ToolItem images.

Re: SWT 4.25 ToolBar ToolItem icon image wrong transparent color [message #1855041 is a reply to message #1854944] Sun, 25 September 2022 19:23 Go to previous messageGo to next message
Andy Maleh is currently offline Andy MalehFriend
Messages: 75
Registered: March 2020
Location: Montreal, Quebec, Canada
Member
It works fine for me under SWT 4.25

Here is Hello, Tool Bar! working on Linux, Mac, and Windows with cut/copy/paste images having transparency show the grey color of the window beneath:
https://imgur.com/a/JwSA0Pr

Linux:
https://i.imgur.com/9YZIxiB.png

Mac:
https://i.imgur.com/At48OsD.png

Windows:
https://i.imgur.com/CzEXhqE.png

The GUI code in Glimmer DSL for SWT (equivalent to the Java code you shared):
      tool_bar {
        tool_item {
          image File.expand_path('./images/cut.png', __dir__), height: 16
        }
        tool_item {
          image File.expand_path('./images/copy.png', __dir__), height: 16
        }
        tool_item {
          image File.expand_path('./images/paste.png', __dir__), height: 16
        }
        tool_item(:separator)
        combo {
          selection <=> [self, :font_size]
        }
      }


Full code: https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_tool_bar.rb

What operating system are you encountering the problem on?

Could it be you are using an image without proper transparency?


EclipseCon / EclipseWorld / Agile Conference Speaker
Open-Source Software Author of Glimmer DSL for SWT
Re: SWT 4.25 ToolBar ToolItem icon image wrong transparent color [message #1855083 is a reply to message #1855041] Wed, 28 September 2022 05:54 Go to previous messageGo to next message
Martin J is currently offline Martin JFriend
Messages: 50
Registered: August 2015
Member
Actually I use CoolBar not ToolBar.

CoolBar coolbar = new CoolBar(shell, SWT.NONE);
CoolItem coolitem = new CoolItem(coolbar, SWT.NONE);
SWTToolBar toolbar = new SWTToolBar(coolbar, SWT.NONE);
Point size = toolbar.computeSize (SWT.DEFAULT, SWT.DEFAULT);
coolitem.setPreferredSize (coolitem.computeSize(size.x, size.y));
coolitem.setControl(toolbar);

ToolBar toolbar1 = (ToolBar)coolitem.getControl();
ToolItem item = new ToolItem(toolbar1, SWT.NONE);
Image image = getImageFromResources("C:\....");
item.setImage(image);

Background image of coolbar toolitem is white. It should be gray!


Re: SWT 4.25 ToolBar ToolItem icon image wrong transparent color [message #1855087 is a reply to message #1855083] Wed, 28 September 2022 07:57 Go to previous messageGo to next message
Martin J is currently offline Martin JFriend
Messages: 50
Registered: August 2015
Member
SWTToolBar toolbar = new SWTToolBar(coolbar, SWT.NONE);

should be;

ToolBar toolbar = new ToolBar(coolbar, SWT.NONE);
Re: SWT 4.25 ToolBar ToolItem icon image wrong transparent color [message #1855116 is a reply to message #1855087] Thu, 29 September 2022 04:23 Go to previous messageGo to next message
Martin J is currently offline Martin JFriend
Messages: 50
Registered: August 2015
Member
PS:

I use Windows 10 and 11.
Re: SWT 4.25 ToolBar ToolItem icon image wrong transparent color [message #1855368 is a reply to message #1855116] Mon, 10 October 2022 23:46 Go to previous messageGo to next message
Andy Maleh is currently offline Andy MalehFriend
Messages: 75
Registered: March 2020
Location: Montreal, Quebec, Canada
Member
I just tried the `cool_bar` on the Mac (my work computer), and transparency definitely works. I even tried to change the `cool_bar` background to red, and that showed through the toolbar icons.

Cool Bar:

https://imgur.com/IYzx4u5

https://i.imgur.com/IYzx4u5.png

Cool Bar with Red Background:

https://imgur.com/eKjHbf4

https://i.imgur.com/eKjHbf4.png

Code Snippet in Glimmer DSL for SWT:

      
      ...
      cool_bar {      
        tool_bar {
          tool_item {
            image File.expand_path('./images/cut.png', __dir__), height: 16
            ...
          }
          ...
        }
      }
      ...


When I get a chance, I will test on Windows and Linux too.

What platform are you on (I think I asked you already before.. I'm still wondering what the answer is)?


EclipseCon / EclipseWorld / Agile Conference Speaker
Open-Source Software Author of Glimmer DSL for SWT

[Updated on: Mon, 10 October 2022 23:55]

Report message to a moderator

Re: SWT 4.25 ToolBar ToolItem icon image wrong transparent color [message #1855369 is a reply to message #1855368] Mon, 10 October 2022 23:51 Go to previous messageGo to next message
Andy Maleh is currently offline Andy MalehFriend
Messages: 75
Registered: March 2020
Location: Montreal, Quebec, Canada
Member
By the way, I might have just noticed a difference between my code and yours.

I always pass style
SWT.PUSH
to the `ToolItem` class by default. I wonder if this is somehow affecting transparency.

Try to pass the same SWT style and see if it resolves your issue.


EclipseCon / EclipseWorld / Agile Conference Speaker
Open-Source Software Author of Glimmer DSL for SWT
Re: SWT 4.25 ToolBar ToolItem icon image wrong transparent color [message #1855370 is a reply to message #1855369] Mon, 10 October 2022 23:59 Go to previous messageGo to next message
Andy Maleh is currently offline Andy MalehFriend
Messages: 75
Registered: March 2020
Location: Montreal, Quebec, Canada
Member
I just also noticed that the way Glimmer DSL for SWT builds the image internally by default is different from your code in building the Image.

Here is the image-building JRuby code that is inside the Glimmer DSL for SWT framework, simplified a bit for sharing:
          image_data = ImageData.new(file_path)
          swt_image = Image.new(DisplayProxy.instance.swt_display, image_data)


The gist of the code is that it builds ImageData from the file first, and then it builds the Image. I wonder if that better respects the Image transparency if it contained any.

Try to do the equivalent of that in your Java code too and see if it makes a difference.


EclipseCon / EclipseWorld / Agile Conference Speaker
Open-Source Software Author of Glimmer DSL for SWT

[Updated on: Tue, 11 October 2022 00:01]

Report message to a moderator

Re: SWT 4.25 ToolBar ToolItem icon image wrong transparent color [message #1855436 is a reply to message #1855370] Fri, 14 October 2022 06:44 Go to previous messageGo to next message
Martin J is currently offline Martin JFriend
Messages: 50
Registered: August 2015
Member
I check with Mac. It's fine on Mac. The problem is on Windows. This problem appears from 4.25 onwards. It's SWT bug. I need to report to developers. But they closed down bug report.
Re: SWT 4.25 ToolBar ToolItem icon image wrong transparent color [message #1855471 is a reply to message #1855436] Sun, 16 October 2022 22:55 Go to previous messageGo to next message
Andy Maleh is currently offline Andy MalehFriend
Messages: 75
Registered: March 2020
Location: Montreal, Quebec, Canada
Member
I checked on Windows 10 with SWT 4.25. It looks fine for me.

https://i.imgur.com/masb0iY.png

I even set the background color to red on the ToolBar to prove that the icon image transparency is showing the background through.

https://i.imgur.com/otOJhuI.png


EclipseCon / EclipseWorld / Agile Conference Speaker
Open-Source Software Author of Glimmer DSL for SWT

[Updated on: Sun, 16 October 2022 22:56]

Report message to a moderator

Re: SWT 4.25 ToolBar ToolItem icon image wrong transparent color [message #1855489 is a reply to message #1855471] Tue, 18 October 2022 01:48 Go to previous message
Martin J is currently offline Martin JFriend
Messages: 50
Registered: August 2015
Member
You are correct. Toolbar works correctly. The problem was that ImageData scaling algo is slightly different in new SWT 2.25 onwards. So transparency didn't work.

Thanks for help.
Previous Topic:Glimmer
Next Topic:HTML browser img tag does not use aspect ratio
Goto Forum:
  


Current Time: Sat Apr 20 00:08:44 GMT 2024

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

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

Back to the top