古い位置から新しい座標にピクセルをコピーすることにより、Java 上の既存の画像に境界線を追加する画像を作成しようとしています。これまでのところ、これは私がやったことです:
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 < w; x++) {
for (int y = 0; y < h; y++) {
tgt[y][x + y + borderWidth] = src[x][y]; // this is probably where I a messing up
}
}
return new NewPic(tgt);
}
コメントした行で何が間違っているのかわかりません。私はJavaが初めてです。誰かが私にいくつかのガイダンスを与えることができますか?