[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[platform-swt-dev] Image effect
|
hello there im trying to do a image effect simillar to the one in
windows explorer , when you click one icon ( color of widget background
ont top )
my problem is that i dont know how to intersect the two colors with the
tranparency . I tryed to do like this :
- draw the original image
- draw the transparent color on top
- get the image data of the original image
- gc.copyarea()
- intersect the absolute tranparent pixels
-redraw the result
the result is what i whant but the time it takes =\ not really .
---- heres the mess -----
Image image = null;
Image iconImage ;
ImageData imgData = _img.getImageData();
Display display = FileExplorer.getDisplay();
Color highlight =
display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
Color white = display.getSystemColor(SWT.COLOR_WHITE);
Image icon = new Image(display,1,1);
GC tmpGc = new GC(icon);
tmpGc.setForeground(highlight);
tmpGc.drawPoint(0,0);
tmpGc.dispose();
ImageData iconData = icon.getImageData();
iconData.setAlpha(0,0, 150);
icon = new Image(display,iconData);
GC gc = new GC(_imgFrame);
gc.drawImage(icon, 0, 0, 1, 1, 0, 0,
_imgFrame.getBounds().width, _imgFrame.getBounds().height);
icon = new
Image(display,_imgFrame.getBounds().width,_imgFrame.getBounds().height);
gc.copyArea(icon,0,0);
iconData = icon.getImageData();
for(int x = 0 ; x < _img.getBounds().width ; x++){
for(int y = 0 ; y < _img.getBounds().height ; y++){
int alpha = imgData.getAlpha(x,y);
System.out.println(alpha);
iconData.setAlpha(x+5,y+5,alpha);
}
}
icon = new Image(display,iconData);
gc.setBackground(white);
gc.fillRectangle(0,0,_imgFrame.getBounds().width,_imgFrame.getBounds().height);
gc.drawImage(icon,0,0);
gc.dispose();