public static Image createReflectedResizedImage(final Image source,final int newWidth,final int newHeight){
  if (source == null) {
    return null;
  }
  if (source.isDisposed()) {
    SWT.error(SWT.ERROR_WIDGET_DISPOSED);
  }
  final Image newImage=new Image(source.getDevice(),newWidth,(int)(newHeight * 1.5));
  final GC gc=new GC(newImage);
  gc.setAntialias(SWT.ON);
  gc.setInterpolation(SWT.HIGH);
  gc.drawImage(source,0,0,source.getBounds().width,source.getBounds().height,0,0,newWidth,newHeight);
  final Transform t=new Transform(source.getDevice());
  t.setElements(1,0,0,-.5f,0,(float)(newHeight * 1.5));
  gc.setTransform(t);
  gc.drawImage(source,0,0,source.getBounds().width,source.getBounds().height,0,0,newWidth,newHeight);
  t.dispose();
  gc.dispose();
  final ImageData imgData=newImage.getImageData();
  final int width=imgData.width;
  final int height=imgData.height;
  final byte[] alphaData=new byte[height * width];
  final byte[] noAlpha=new byte[width];
  for (int x=0; x < width; x++) {
    noAlpha[x]=(byte)255;
  }
  for (int y=0; y < height; y++) {
    final byte[] alphaRow=new byte[width];
    if (y < newHeight) {
      System.arraycopy(noAlpha,0,alphaData,y * width,width);
    }
 else {
      for (int x=0; x < width; x++) {
        alphaRow[x]=(byte)(255 - 255 * y / height);
      }
      System.arraycopy(alphaRow,0,alphaData,y * width,width);
    }
  }
  imgData.alphaData=alphaData;
  return new Image(source.getDevice(),imgData);
}

public static Image createReflectedResizedImage ( final Image source , final int newWidth , final int newHeight ) { if ( source == null ) { return null ; } if ( source . isDisposed ( ) ) { SWT . error ( SWT . ERROR_WIDGET_DISPOSED ) ; } final Image newImage = new Image ( source . getDevice ( ) , newWidth , ( int ) ( newHeight * 1.5 ) ) ; final GC gc = new GC ( newImage ) ; gc . setAntialias ( SWT . ON ) ; gc . setInterpolation ( SWT . HIGH ) ; gc . drawImage ( source , 0 , 0 , source . getBounds ( ) . width , source . getBounds ( ) . height , 0 , 0 , newWidth , newHeight ) ; final Transform t = new Transform ( source . getDevice ( ) ) ; t . setElements ( 1 , 0 , 0 , - .5f , 0 , ( float ) ( newHeight * 1.5 ) ) ; gc . setTransform ( t ) ; gc . drawImage ( source , 0 , 0 , source . getBounds ( ) . width , source . getBounds ( ) . height , 0 , 0 , newWidth , newHeight ) ; t . dispose ( ) ; gc . dispose ( ) ; final ImageData imgData = newImage . getImageData ( ) ; final int width = imgData . width ; final int height = imgData . height ; final byte [ ] alphaData = new byte [ height * width ] ; final byte [ ] noAlpha = new byte [ width ] ; for ( int x = 0 ; x < width ; x ++ ) { noAlpha [ x ] = ( byte ) 255 ; } for ( int y = 0 ; y < height ; y ++ ) { final byte [ ] alphaRow = new byte [ width ] ; if ( y < newHeight ) { System . arraycopy ( noAlpha , 0 , alphaData , y * width , width ) ; } else { for ( int x = 0 ; x < width ; x ++ ) { alphaRow [ x ] = ( byte ) ( 255 - 255 * y / height ) ; } System . arraycopy ( alphaRow , 0 , alphaData , y * width , width ) ; } } imgData . alphaData = alphaData ; return new Image ( source . getDevice ( ) , imgData ) ; }
create a reflected and resized version of an image
