by Dinesh Thakur

 

import java.awt.*;

import java.awt.image.*;
import java.applet.*;
/*<APPLET CODE=JavaExampleEmbossInApplet.class WIDTH=300 HEIGHT=300 ></APPLET>*/
public class JavaExampleEmbossInApplet extends Applet
  {
       Image img,img1;
       public void init()
         {
              img = getImage(getDocumentBase(),"snow.gif");
              int pxls[] = new int[248 * 248];
              PixelGrabber PxlGrbr = new PixelGrabber(img, 0, 0, 248,248, pxls,0,248);
              try
             {
                    PxlGrbr.grabPixels();
                 }
                    catch (InterruptedException e1) {}
                    for (int x = 2; x < 247; x++)
                        {
                           for (int y = 2; y < 247; y++)
                            {
                                     int red = ((pxls[(x + 1) * 248 + y + 1] & 0xFF) -(pxls[x * 248 + y] & 0xFF)) + 128;
                                     int green = (((pxls[(x + 1) * 248 + y + 1] & 0xFF00) / 0x100) % 0x100 - ((pxls[x * 248 + y] & 0xFF00) / 0x100) % 0x100) + 128;
                                     int blue = (((pxls[(x + 1) * 248 + y + 1] & 0xFF0000) / 0x10000) % 0x100 - ((pxls[x * 248 + y] & 0xFF0000) / 0x10000) % 0x100) + 128;
                                     int avg = (red + green + blue) / 3;pxls[x * 248 + y] = (0xff000000 | avg << 16 | avg << 8 | avg);
                                }
                      }
                                    img = createImage(new MemoryImageSource(248,248,pxls,0,248));
         }
                                    public void paint(Graphics gr)
                                      {
                                          gr.drawImage(img, 0, 0, this);
                                      }
  }
Emboss Java Applet Example