a1.html
<applet code="zzz" width=350 height=300></applet>
zzz.java programs
The import statements for the programs
Program 1
Program 2import java.awt.*; import java.awt.image.*; import java.applet.Applet; public class zzz extends Applet implements ImageObserver { Image o; Image c; ImageProducer p; public void init () { o = getImage(getDocumentBase(),"joe.surf.yellow.small.gif"); ImageFilter f = new ImageFilter(); p=new FilteredImageSource(o.getSource(),f); c=createImage(p); } public void paint(Graphics g) { g.drawImage(c,0,0,this); g.drawImage(o,150,150,this); } public synchronized boolean imageUpdate(Image m, int a,int x, int y, int w, int h) { repaint(100); return true; } }
Program 3public class zzz extends Applet implements ImageObserver { Image o; Image c; ImageProducer p; public void init () { o = getImage(getDocumentBase(),"joe.surf.yellow.small.gif"); fff f = new fff(); p=new FilteredImageSource(o.getSource(),f); c=createImage(p); } public void paint(Graphics g) { g.drawImage(c,0,0,this); g.drawImage(o,150,150,this); } public synchronized boolean imageUpdate(Image m, int a,int x, int y, int w, int h) { repaint(100); return true; } } class fff extends ImageFilter { public void setPixels(int x,int y,int w,int h,ColorModel d, byte p[],int o,int s) { consumer.setPixels(x,y,w,h,d,p,o,s); } }
Program 4public class zzz extends Applet implements ImageObserver { Image o; Image c; ImageProducer p; public void init () { o = getImage(getDocumentBase(),"joe.surf.yellow.small.gif"); fff f = new fff(); p=new FilteredImageSource(o.getSource(), f); c=createImage(p); } public void paint(Graphics g) { g.drawImage(c,0,0,this); g.drawImage(o,150,150,this); } public synchronized boolean imageUpdate(Image m, int a,int x, int y, int w, int h) { repaint(100); return true; } } class fff extends ImageFilter { public void setPixels(int x,int y,int w,int h,ColorModel d,byte p[], int o,int s) { System.out.println("x="+x+" y="+y+" w="+w+" h="+h+" o="+o+" s="+s); int u[] = new int[w]; for (int i = 0; i < w; i++) { u[i] = d.getRGB((p[i] & 0xff)); } consumer.setPixels(x,y,w,h,ColorModel.getRGBdefault(),u,o,s); } }
Program 5class fff extends ImageFilter { public void setPixels(int x,int y,int w,int h,ColorModel d,byte p[], int o,int s) { System.out.println("x="+x+" y="+y+" w="+w+" h="+h+" o="+o+" s="+s); int u[] = new int[w]; for (int i = 0; i < w; i++) { u[99-i] = d.getRGB((p[i] & 0xff)); } consumer.setPixels(x,y,w,h,ColorModel.getRGBdefault(),u,o,s); } }
Program 6class fff extends ImageFilter { public void setPixels(int x,int y,int w,int h,ColorModel d,byte p[], int o,int s) { System.out.println("x="+x+" y="+y+" w="+w+" h="+h+" o="+o+" s="+s); int u[] = new int[w]; for (int i = 0; i < w; i++) { u[i] = d.getRGB((p[i] & 0xff)); } consumer.setPixels(x,(115-y),w,h, ColorModel.getRGBdefault(),u,o,s); } }
Program 7class fff extends ImageFilter { public void setPixels(int x,int y,int w,int h,ColorModel d,byte p[], int o,int s) { System.out.println("x="+x+" y="+y+" w="+w+" h="+h+" o="+o+" s="+s); int u[] = new int[w]; for (int i = 0; i < w; i++) { u[i] = d.getRGB((p[i] & 0xff)); } consumer.setPixels(x,y,w/2,h, ColorModel.getRGBdefault(),u,o,s); } }
Program 8class fff extends ImageFilter { public void setPixels(int x,int y,int w,int h,ColorModel d,byte p[], int o,int s) { System.out.println("x="+x+" y="+y+" w="+w+" h="+h+" o="+o+" s="+s); int u[] = new int[w]; for (int i = 0; i < w; i++) { u[i] = d.getRGB((p[i] & 0xff)); } consumer.setPixels(x,y,w,h, ColorModel.getRGBdefault(),u,50,s); } }
Program 9class fff extends ImageFilter { public void setPixels(int x,int y,int w,int h,ColorModel d,byte p[], int o,int s) { System.out.println("x="+x+" y="+y+" w="+w+" h="+h+" o="+o+" s="+s); int u[] = new int[w]; for (int i = 0; i < w; i++) { u[i] = d.getRGB((p[i] & 0xff)); } consumer.setPixels(x,y+50,w,h,ColorModel.getRGBdefault(), u,o,s); } }
class fff extends ImageFilter { int i = 0; public void setPixels(int x, int y, int w, int h, ColorModel d, byte p[], int o,int s) { int u[] = new int[w]; for (int i = 0; i < w; i++) { u[i] = d.getRGB((p[i] & 0xff)); if ( i >= 10 && i <= 50) u[i]= u[i] & 0xffffffff; else u[i]= u[i] & 0x00ffffff; } consumer.setPixels(x,y,w,1,ColorModel.getRGBdefault(),u,0,s); } }
Wanna give Leonardo the goose pimples, get to the next topic "Giving Leonardo the goosies " or just reach your mail i.e., your comments, feedback, suggestions et al to us.