Here's a runnable example in case you wanted to see the results

import java.io.*;
import java.awt.image.*;
import java.awt.Image;
import java.awt.Graphics2D;
import java.awt.Toolkit;
import javax.swing.*;
import java.awt.MediaTracker;
import java.awt.Graphics;

public class Sample extends JFrame {
  BufferedImage aBufferedImage;

  public Sample() {
    super("Testing");
    setSize(500,500);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setVisible(true);

    Image im = Toolkit.getDefaultToolkit().createImage("C:/Windows/phrase.jpg");

    MediaTracker tracker = new MediaTracker(this);
    tracker.addImage(im, 0);
    try {tracker.waitForID(0);}
    catch (InterruptedException e) {}

   aBufferedImage = createStorage(im.getWidth(this),im.getHeight(this));
   drawIn(aBufferedImage, im);
   applyKernel(0,0);
    }

  public void applyKernel(int x, int y) {
   for(int i=-1; i<2; i++) {
     for(int j=-1; j<2; j++) {
       try {
         aBufferedImage.getRGB(i + x, j + y);
         System.out.println("Good");
         }
        catch(ArrayIndexOutOfBoundsException e) {System.out.println("Bad");}   // 
Ignore exception
       }
     }
   }

  static public BufferedImage createStorage(int w, int h) {
   return (new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB));
    }

  public void drawIn(BufferedImage bimg, Image anImage) {
   Graphics2D g2 = bimg.createGraphics();
   g2.drawImage(anImage, null, null);
    }

  public void paint(Graphics g) {
   if (aBufferedImage != null) {
     g.drawImage(aBufferedImage, 50, 50, this);
      }
    }

    public static void main(String args[]) {
     Sample aSample = new Sample();
    }
  }

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to