Small problem: In order to improve the perf of a given map, I need to create layers ... In Swing, no problem: we have the JLayeredPane SWT ... but that neni!
So here's a little trick to create transparent images (the background maps have generally need to be calculated only once!)
- / / Set the color that will be considered transparent
- ( ) . getSystemColor ( SWT. COLOR_WHITE ) ; LTransparentColor = Color Display. GetDisplay (). GetSystemColor (SWT. color_white);
- / / Create a palette with transparent color and all other
- / / Necessary color to the image (here lOtherColor)
- new RGB [ ] { PaletteData lPalette PaletteData = new (new RGB [] (
- , lTransparentColor. getRGB ()
- lOtherColor. getRGB ()
- ));
- / / Create the image with the palette
- lWidth, lHeight, 2 , lPalette ) ; LImageData ImageData = new ImageData (lWidth, lHeight, 2, lPalette);
- / / Set the transparent color of the image (white here)
- ( lTransparentColor. getRGB ( ) ) ; lImageData. transparentPixel = lPalette. getPixel (lTransparentColor. getRGB ());
- / / And now!
- ( lDisplay, lImageData ) ; filing = new Image (lDisplay, lImageData);
- ( ) ; Rectangle = lImageBounds filing. GetBounds ();
- / / The GC will draw in the image
- lImage ) ; GC LGC = new GC (filing);
- / / First step: complete the picture of a completely transparent background
- lTransparentColor ) ; LGC. setbackground (lTransparentColor);
- lImageBounds ) ; LGC. FillRectangle (lImageBounds);
- / / And now remains is to draw as before in the GC!
This is a first step towards drawing in layers ... I will return later with a small lib ...




Comments
Write a comment Trackback