[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Help with Painting !!


Hello,

Please help me overcome this issue with painting a image before placing it on the composite.


Region (a) is white and transparent. Region (b) is black. The image has 2 colors and is depth is I bit per pixel.

|-------------------|
| (a) |
| |
| |---------| |
| | | |
| | | |
| | (b) | |
| | | |
| |---------| |
| |
| |
|-------------------|
When I place this image on a composite region (a) correctly get the color of the composite it lies on.
Now I want to change region (b) to have the foreground color of the composite.


Problem 1.
==========
I cannot chage the color of region (b) to the forground color of the composite it is on.
Problem 2
==========
If the fore ground color of the composite is white, changing the color of region (b) to white will make it transparent too as the transparent color is white.



Code
====
Here is what I do , if I find a black pixel I change it to white which makes the complete image transparent.
If I use any value other than FFFFFF region (b)becomes black.


I am clueless... HELP!!!

for(int i=0; i<img_data.width; i++) {
   for(int j=0; j<img_data.height; j++) {
     RGB rgb = img_data.palette.getRGB(img_data.getPixel(i, j));
     int threshold = 0;

if(rgb.red == threshold && rgb.green == threshold && rgb.blue == threshold)
img_data.setPixel(i, j, 0xFFFFFF);


   }
 }



-Chhil
p.s. I have posted a similar post earlier.