Community
Participate
Working Groups
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.
PRODUCT VERSION: 120
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.
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().
This has been fixed in 2.0.