'image.getRgb()'APIの使用方法を理解しようとしています。テストのために、正確な画像をコピーして表示しましたが、コードで機能させることができませんでした。
int picWidth = (int) image.width();
int picHeight = (int) image.height();
buf = new int[picWidth * picHeight];
image.getRgb(0, 0, picWidth, picHeight, buf, 0, picWidth);
int color = 0;
for(int y=0; y < picHeight; y ++) {
for(int x=0; x < picWidth; x++) {
color = buf[x*y];
layer.surface().setFillColor(color);
layer.surface().fillRect(x,y, 1, 1);
}
}
上記のコードは、ピクセルごとにバッファにコピーしてから、まったく同じ画像を表面に表示することを期待しています。ただし、これが私の元の写真と結果の写真です。
元の画像
結果画像
getRgb()APIを誤解していると思いますが、正しい使用方法は何ですか?ありがとう。