The plot thickens

This page is currently putting up with massive transmutation and that is precisely why only the lonely code will have to make do. We will be back here soon, but till then, Thanx for visiting this page. If you are a member of the Java-crazed community, you can still try out the code furnished here. Maybe with some divine intervention you might be able to get the drift...


a1.html

<applet code="zzz" width=350 height=300></applet>

zzz.java programs

The import statements for the programs

Program 1

import 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 2
public 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 3
public 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 4
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[99-i] = d.getRGB((p[i] & 0xff));
                }
                consumer.setPixels(x,y,w,h,ColorModel.getRGBdefault(),u,o,s);
        }
}
Program 5
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,(115-y),w,h,
                ColorModel.getRGBdefault(),u,o,s);
        }
}
Program 6
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/2,h,
                ColorModel.getRGBdefault(),u,o,s);
        }
}
Program 7
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,50,s);
        }
}
Program 8
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+50,w,h,ColorModel.getRGBdefault(),
                u,o,s);
        }
}
Program 9
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.

Back to our Java page


Vijay Mukhi's Computer Institute
B-13, Everest Building, Tardeo, Bombay 400 034, India.
http://www.neca.com/~vmis
e-mail : vmukhi@giasbm01.vsnl.net.in
1