adding a border in Java
<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. My solution is working, but I was wondering if there is a more efficient/shorter way to do this.</p>

<pre><code> /** Create a new image by adding a border to a specified image. 
 * 
 * @param p
 * @param borderWidth  number of pixels in the border
 * @param borderColor  color of the border.
 * @return
 */
    public static NewPic border(NewPic p, int borderWidth, Pixel borderColor) {
    int w = p.getWidth() + (2 * borderWidth); // new width
    int h = p.getHeight() + (2 * borderWidth); // new height

    Pixel[][] src = p.getBitmap();
    Pixel[][] tgt = new Pixel[w][h];

    for (int x = 0; x &lt; w; x++) {
        for (int y = 0; y &lt; h; y++) {
            if (x &lt; borderWidth || x &gt;= (w - borderWidth) || 
                y &lt; borderWidth || y &gt;= (h - borderWidth))
                    tgt[x][y] = borderColor;
            else 
                tgt[x][y] = src[x - borderWidth][y - borderWidth];

        }
    }

    return new NewPic(tgt);
    }
</code></pre>
