古い位置から新しい座標にピクセルをコピーすることにより、Java 上の既存の画像に境界線を追加する画像を作成しようとしています。私のソリューションは機能していますが、これを行うためのより効率的/短い方法があるかどうか疑問に思っていました.
 /** 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 < w; x++) {
        for (int y = 0; y < h; y++) {
            if (x < borderWidth || x >= (w - borderWidth) || 
                y < borderWidth || y >= (h - borderWidth))
                    tgt[x][y] = borderColor;
            else 
                tgt[x][y] = src[x - borderWidth][y - borderWidth];
        }
    }
    return new NewPic(tgt);
    }