Java sample(Round images)


run

---(Source List)---

//Example09
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
public class Example09 extends Frame{
  Image img01;
  //Main
  public static void main(String ar[]){
    Frame f=new Example09();
    f.setTitle("Round images");
    f.setSize(new Dimension(640,400));
    f.setVisible(true);
  }
  //Parts set
  Example09(){
    img01=getToolkit().getImage("ICO_020.gif");
    addWindowListener(new WinAdapter());
  }
  //Close
  class WinAdapter extends WindowAdapter{
    public void windowClosing(WindowEvent we){System.exit(0);}
  }
  //Paint
  public void update(Graphics g){
    paint(g);
  }
  public void paint(Graphics g){
    int w,h;
    Image img;
    PixelGrabber pg=new PixelGrabber(img01,0,0,-1,-1,true);
    try{
      if(pg.grabPixels()){
        w=pg.getWidth();
        int[] op=(int[]) pg.getPixels();
        int[] np=(int[]) new int[w*w];
        g.drawImage(img01,0,100,this);
        for(int y=0;y<w;y++){
          for(int x=0;x<w;x++) np[(w-1-y)+x*w]=op[x+y*w];
        }
        img=createImage(new MemoryImageSource(w,w,np,0,w));
        g.drawImage(img,50,100,this);
        for(int y=0;y<w;y++){
          for(int x=0;x<w;x++) np[(w-1-x)+(w-1-y)*w]=op[x+y*w];
        }
        img=createImage(new MemoryImageSource(w,w,np,0,w));
        g.drawImage(img,100,100,this);
        for(int y=0;y<w;y++){
          for(int x=0;x<w;x++) np[y+(w-1-x)*w]=op[x+y*w];
        }
        img=createImage(new MemoryImageSource(w,w,np,0,w));
        g.drawImage(img,150,100,this);
      }
    }catch(InterruptedException ie){}
  }
}