-2

今日、notch が HerpFortress という 2D ゲームを作成しているビデオを見ていたら、説明できないエラーが表示されました ( http://pt.twitch.tv/notch/b/309642636 (0:42:44) ) ,そして私は彼のコードに従っていましたが、この行でエラーが発生しました...

img.getRGB(x * sw, y * sh, sw, sh, result [x][y].pixels, 0, sw);

エラーは、

The method getRGB(int, int, int, int, int[], int, int) in the type BufferedImage is not applicable for the arguments (int, int, int, int, int, int, int)

ヘルプ ?

4

2 に答える 2

1
img.getRGB(x * sw, y * sh, sw, sh, result [x][y].pixels, 0, sh);

結果のエラー[x][y].pixels :---> これは配列ではなく値です。この場所のこのメソッドは、データが書き込まれる配列を取得します この例のように:

int[] outPixels = new int[width*height];
img.getRGB( 0, 0, width, height, outPixels, 0, width );

メソッド:

getRGB(startX, startY, w, h, rgbArray, offset, scansize)

パラメーター:

startX - the starting X coordinate
startY - the starting Y coordinate 
w - width of region h - height of region 
rgbArray - if not null, the rgb pixels are written here 
offset - offset into the rgbArray scansize - scanline stride for the rgbArray
于 2013-04-02T19:01:46.420 に答える
1

エラーメッセージ自体が、何が問題なのかを示しています。このgetRGBメソッドは、5 番目のパラメーターに整数の配列 ( ) を想定しており、コードからは明らかではint[]ありませんが、プレーンを提供している必要があります。intresult [x][y].pixels

于 2013-04-02T19:00:35.183 に答える