Bug 4714 - Label draws wrong background when image is set (1GF0IC6)
Summary: Label draws wrong background when image is set (1GF0IC6)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0   Edit
Hardware: All Windows NT
: P4 normal (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-11 14:21 EDT by Eduardo Pereira CLA
Modified: 2001-11-22 16:04 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eduardo Pereira CLA 2001-10-11 14:21:46 EDT
Run the following code in a 256 color mode Windows NT. The image
is not transparent as it should be.

Display display = new Display();
Shell shell = new Shell(display);
RGB rgb = new RGB(230, 226, 221);
Color color = new Color(display, rgb);
Image img = new Image(display, 20, 20);
GC gc = new GC(img);
gc.setBackground(color);
gc.fillOval(0, 0, 20, 20);
gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
gc.fillOval(0, 0, 20, 20);
gc.dispose();
ImageData data = img.getImageData();
data.transparentPixel = data.palette.getPixel(rgb);
//ImageData data = new ImageData("D:\\eduardo\\desktop\\ide\\project_resources\\Eclipse JFace\\org\\eclipse\\jface\\dialogs\\images\\title_error.gif");
Image image = new Image(display, data, data.getTransparencyMask());
Label label = new Label(shell, SWT.NONE);
label.setBackground(color);
shell.setBackground(color);
label.setSize(100, 30);
//label.setText("ERROR");
label.setImage(image);
label.setSize(100, 100);
shell.open();

while (!shell.isDisposed()) {
	if (!display.readAndDispatch()) display.sleep();
}

NOTES:

	McQ (11/06/2001 9:18:43 AM) -
		Do we still fake transparency for labels by setting the "transparent" pixels
		to the background color? If so, this could just be a failed closest match issue.
Comment 1 DJ Houghton CLA 2001-10-29 16:33:09 EST
PRODUCT VERSION:

120

Comment 2 Mike Wilson CLA 2001-11-22 10:17:29 EST
The previous comment I made still applies. However, this would imply that the 
o/s does not make available in the palette we are using the background color 
that *it* chose in the widget.
Comment 3 Silenio Quarti CLA 2001-11-22 14:21:32 EST
The image being drawn is an icon, so the fake transparency code
is not running. The problem is the label is not selecting the
display palette when it erases the background in Label.WM_ERASEBKGND().
Comment 4 Silenio Quarti CLA 2001-11-22 16:04:04 EST
This has been fixed in 2.0.