title: Adding a border to an image in Java
body: <p>I am trying to create an image that adds a border to an existing image on Java by copying the pixels from their old locations to new coordinates. So far, this is what I have done:</p>
  
  <pre><code>public static NewPic border (NewPic p, int borderWidth, Pixel borderColor) {
     int w = p.getWidth();
     int h = p.getHeight();
  
     Pixel src[][] = p.getBitmap();
     Pixel tgt[][] = new Pixel[h][w];
  
     for (int x = 0; x &lt; w; x++) {
       for (int y = 0; y &lt; h; y++) {
         tgt[y][x + y + borderWidth]  = src[x][y]; // this is probably where I a messing up
       }
    }
    return new NewPic(tgt);
    }
  </code></pre>
  
  <p>Not sure what I am doing wrong in the line where I commented. I am new to Java. Can someone give me some guidance?</p>