<applet code="zzz" width=350 height=300></applet>
zzz.java programs
Program 1
Program 2import java.applet.*; import java.awt.*; public class zzz extends Applet { public boolean mouseUp(Event e , int x, int y) { showStatus("Code:"+getCodeBase().toString()+"..."+"Document:"+ getDocumentBase().toString()); return true; } }
Program 3import java.applet.*; import java.awt.*; public class zzz extends Applet { Image o; public void init() { o=getImage(getDocumentBase(),"joe.surf.yellow.small.gif"); } public void paint(Graphics g) { g.drawImage(o,150,150,this); } }
Program 4import java.applet.*; import java.awt.*; public class zzz extends Applet { Image o,c; public void init() { o=getImage(getDocumentBase(),"joe.surf.yellow.small.gif"); c=createImage(o.getSource()); } public void paint(Graphics g) { g.drawImage(c,0,0,this); g.drawImage(o,150,150,this); } }
The import commands for the following programsimport java.applet.*; import java.awt.*; import java.awt.image.*; public class zzz extends Applet { Image o,c; ImageProducer p; public void init() { o=getImage(getDocumentBase(),"joe.surf.yellow.small.gif"); p=o.getSource(); c=createImage(p); } public void paint(Graphics g) { g.drawImage(c,0,0,this); g.drawImage(o,150,150,this); } }
Program 5import java.applet.*; import java.awt.*; import java.awt.image.*;
Program 6public class zzz extends Applet { Image o,c; ImageProducer p; ImageFilter f; public void init() { o=getImage(getDocumentBase(),"joe.surf.yellow.small.gif"); p=o.getSource(); f=new ImageFilter(); p=new FilteredImageSource(p,f); c=createImage(p); } public void paint(Graphics g) { g.drawImage(c,0,0,this); g.drawImage(o,150,150,this); } }
Program 7public class zzz extends Applet { Image o,c; ImageProducer p; ImageFilter f; public void init() { o=getImage(getDocumentBase(),"joe.surf.yellow.small.gif"); p=o.getSource(); f=new RGBImageFilter(); p=new FilteredImageSource(p,f); c=createImage(p); } public void paint(Graphics g) { g.drawImage(c,0,0,this); g.drawImage(o,150,150,this); } } /* Error:RGBImageFilter is an abstract class. It cannot be instantiated */
Program 8public class zzz extends Applet { Image o,c; ImageProducer p; ImageFilter f; public void init() { o=getImage(getDocumentBase(),"joe.surf.yellow.small.gif"); p=o.getSource(); f=new fff(); p=new FilteredImageSource(p,f); c=createImage(p); } public void paint(Graphics g) { g.drawImage(c,0,0,this); g.drawImage(o,150,150,this); } } class fff extends RGBImageFilter { public int filterRGB(int x, int y, int r) { return r; } }
Program 9public class zzz extends Applet { Image o,c; ImageProducer p; ImageFilter f; public void init() { o=getImage(getDocumentBase(),"joe.surf.yellow.small.gif"); p=o.getSource(); f=new fff(); p=new FilteredImageSource(p,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 n, int x, int y, int w, int h) { repaint(1000); return true; } } class fff extends RGBImageFilter { public int filterRGB(int x, int y, int r) { return r&0xff00ffff; } }
If you have tried out the above, replace the fff class in the following ways...public class zzz extends Applet { Image o,c; ImageProducer p; ImageFilter f; public void init() { o=getImage(getDocumentBase(),"joe.surf.yellow.small.gif"); p=o.getSource(); f=new fff(); p=new FilteredImageSource(p,f); c=createImage(p); } public void paint(Graphics g) { g.drawImage(c,0,0,this); g.drawImage(o,150,150,this); } } class fff extends RGBImageFilter { public int filterRGB(int x, int y, int r) { return r&0xff00ffff; } }
Program 10public int filterRGB(int x, int y, int r) { return r & 0x00ffffff; } public int filterRGB(int x, int y, int r) { if ( (r>>24) == 0) return 0xff00ff00 ; else return r; } public int filterRGB(int x,int y, int r) { return ((r & 0xff00ff00) | ((r & 0x00ff0000) >> 16) | ((r & 0x000000ff) << 16)); } public int filterRGB(int x, int y, int r) { if ( (r>>24) == 0) return 0xf000ff00 ; else return r; }
public class zzz extends Applet { Image o; Image c; int i = 0; public void init () { o = getImage(getDocumentBase(),"joe.surf.yellow.small.gif"); pp(); } public boolean mouseDown(Event e,int x,int y) { i++; pp(); repaint(); return true; } public void paint(Graphics g) { g.drawImage(c,0,0,this); } public synchronized boolean imageUpdate(Image m, int f,int x, int y, int w, int h) { repaint(100); return true; } public synchronized void pp() { ImageFilter f; if ( i%2 == 0) f=new xxx(); else f=new yyy(); ImageProducer p = o.getSource(); p = new FilteredImageSource(p, f); c = createImage(p); } } class yyy extends RGBImageFilter { public int filterRGB(int x, int y, int r) { return r; } } class xxx extends RGBImageFilter { public int filterRGB(int x, int y, int r) { return ((r & 0xff00ff00)|((r & 0xff0000) >> 16) |((r & 0xff) << 16)); } }
Please rush to the next topic "The plot thickens" or just reach your messages i.e., your comments, feedback, suggestions et al to us.