code: private int getSourcePixel(int x,int y)
      {
          x = Math.max(0,x);
          x = Math.min(width-1,x);
          y = Math.max(0,y);
          y = Math.min(height-1,y);
          
          return srcImage[x+(y*width)];
      }
docs: Get a pixel from the source image. This handles bonds checks
  and resolves to edge pixels
  
  @param x The x location of the pixel to retrieve
  @param y The y location of the pixel to retrieve
  @return The pixel value at the specified location