public static ImageDescriptor push( final ImageDescriptor icon ){
return new ImageDescriptor(){
@Override
public ImageData getImageData() {
ImageData push = icon.getImageData();
if( !push.palette.isDirect){
RGB[] rgb=new RGB[push.palette.colors.length];
System.arraycopy(push.palette.colors, 0, rgb, 0, push.palette.colors.length);
rgb[push.transparentPixel]=Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW).getRGB();
push.palette=new PaletteData(rgb);
push.transparentPixel=-1;
createBorder(push);
return push;
}
int pushColour=push.palette.getPixel(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW).getRGB());
for( int x = 0; x<push.width; x++ )
for( int y = 0; y<push.height; y++ ){
if( push.getAlpha(x, y) == 0 ){
push.setAlpha(x, y, 255 );
push.setPixel( x, y, pushColour );
}
if( push.getPixel(x,y)==push.transparentPixel ){
push.setPixel( x, y, pushColour);
}
}
return push;
}
private void createBorder( ImageData push ) {
for( int y = 0; y<push.height; y++ ){
for( int x = 0; x<push.width; x++ ){
if( y==0 || x==0 )
push.setPixel(x,y,0);
}
}
}
};