私はこの種の方法を持っています:
public void SaveImageOntoObject(String filepath) throws IOException {
BufferedImage image = ImageIO.read(getClass().getResourceAsStream(filepath));
this.width = image.getWidth();
this.height = image.getHeight();
this.ResetPointInformation();
for (int row = 0; row < width; row++) {
for (int col = 0; col < height; col++) {
this.PointInformation[row][col] = new Color(image.getRGB(col, row));
}
}
}
画像のファイルパスを入力として受け取り、各ピクセルのRPG値をカラーオブジェクトに変換してから、メソッドが呼び出されたオブジェクトの2次元配列PointInformationに格納します。
今私の問題に:
このようないくつかの写真が:
魅力のように働く、他の人はこのように:
エラーが発生します。
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
at sun.awt.image.ByteInterleavedRaster.getDataElements(ByteInterleavedRaster.java:318)
at java.awt.image.BufferedImage.getRGB(BufferedImage.java:888)
at Drawing.Object2D.SaveImageOntoObject(Object2D.java:75)** (that's the class whose object's my method works on)
なんでそんなの?Javaは特定のRGB値を色に変換できないようですか?
どうすればそれを機能させることができるか教えていただけますか?