Bug 196401 - Images with transparency alpha added to the Toolbar widget do not render at all on Windows 2000
Summary: Images with transparency alpha added to the Toolbar widget do not render at a...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Steve Northover CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-12 21:05 EDT by jonathan CLA
Modified: 2019-09-06 16:07 EDT (History)
0 users

See Also:


Attachments
Application to demonstrate the problem (3.68 KB, application/x-zip-compressed)
2007-07-12 21:07 EDT, jonathan CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description jonathan CLA 2007-07-12 21:05:59 EDT
I did much investigation into this and discovered that the SWT Button widget seems to explicitly handle images with transperency alpha on Windows 2000. The Toolbar widget doesn't though. In Button._setImage ():

if (OS.COMCTL32_MAJOR >= 6)  // true for win xp
{
   .....
}
else
{   // win2k
....
case SWT.TRANSPARENCY_ALPHA:
image2 = new Image (display, rect.width, rect.height);
GC gc = new GC (image2);
gc.setBackground (getBackground ());
gc.fillRectangle (rect);
gc.drawImage (image, 0, 0);
gc.dispose ();
hImage = image2.handle;
imageBits = OS.BS_BITMAP;
fImageType = OS.IMAGE_BITMAP;
break;   
...
}

I have attached a test application and an image file (please use this image file) so it will be easy for you to see the issue. 

There are two blocks of code you can uncomment. The first one is the image placed on the Button Widget. You can see that it renders fine on Windows 2000 and XP.

If you uncomment and run the second block of code, the image is placed (via an ActionContributionItem) on to a Toolbar widget. It will render on Windows XP but not show up at all on Windows 2000.

It seems that the Toolbar or ToolItem widgets need to have code similar to what the Button widget does already for transparent images on win2K?

In my application code, I hacked it so that I redraw the image (as above) before adding it to the toolbar and that works. But it seems to me that the proper fix should be in SWT somewhere.

Thanks!
Jonathan
Comment 1 jonathan CLA 2007-07-12 21:07:18 EDT
Created attachment 73713 [details]
Application to demonstrate the problem 

I have attached a test application and an image file (please use this image file) so it will be easy for you to see the issue. 

There are two blocks of code you can uncomment. The first one is the image placed on the Button Widget. You can see that it renders fine on Windows 2000 and XP.

If you uncomment and run the second block of code, the image is placed (via an ActionContributionItem) on to a Toolbar widget. It will render on Windows XP but not show up at all on Windows 2000.
Comment 2 Grant Gayed CLA 2007-07-30 11:09:06 EDT
SN to simplify the test case change TransImageText.main() to the snippet below, and don't take DummyAction.

public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	Image image = new Image(display, "./back.gif");
	ImageData imageData = image.getImageData();
	image.dispose();
	applyOpacityFilter(imageData);
	image = new Image(display, imageData);
	final Button button = new Button(shell, SWT.PUSH);
	button.setBounds(1, 1, 50, 50);
	button.setImage(image);	// works on win2000
	ToolBar bar = new ToolBar(shell, SWT.BORDER);
	bar.setBounds(100, 100, 100, 100);
	ToolItem item = new ToolItem(bar, SWT.NONE);
	item.setImage(image);	// does not work on win2000
	shell.pack();
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) display.sleep();
	}
	image.dispose();
	display.dispose();
}
Comment 3 Eclipse Webmaster CLA 2019-09-06 16:07:09 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.