[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.platform.swt] Image with SWT.IMAGE_GRAY style
|
- From: kkconcome@xxxxxxxxx (Connie)
- Date: Tue, 31 May 2005 22:38:03 +0000 (UTC)
- Newsgroups: eclipse.platform.swt
- Organization: not organized
- User-agent: NewsPortal/0.36 (http://florian-amrhein.de/newsportal)
Hi,
Given an image, I want to be able to do the following:
1. Display the image with transparent background (RGB(0, 255, 255) in my
case).
2. Display the image as being grayed-out and, at the same time, have
transparent background.
I'm able to do this on a GIF and 16 color BMP using the following code:
InputStream inputStream =
test.getClass().getResourceAsStream("..\\..\\icons\\img.bmp");
ImageData imgData = new ImageData(inputStream);
imgData.transparentPixel = imgData.palette.getPixel(new RGB(0, 255, 255));
final Image image = new Image(display, imgData);
final Image disabledImage = new Image(display, image, SWT.IMAGE_GRAY);
shell.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
GC gc = event.gc;
gc.drawImage(image, 0, 0);
gc.drawImage(disabledImage, 50, 0);
}
});
However, I can only get #1 working when I tried the same code on a 24-bit
BMP.
(the 24-bit BMP has the same background color RGB(0, 255, 255) as the
previous
2 images). The grayed-out image does not have a transparent background -
it
has a light gray background instead.
Is this a bug? Is there a solution/workaround for me to fix the problem?
Thanks for your help!
Connie