0
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
    at sun.awt.image.IntegerInterleavedRaster.setDataElements(IntegerInterleavedRaster.java:301)
    at java.awt.image.BufferedImage.setRGB(BufferedImage.java:988)
    at MyManager.imageMan.fazerNova(imageMan.java:354)
    at MyManager.imageMan.main(imageMan.java:472)

我需要一些帮助。

  public static BufferedImage fazerNova(int abc[],BufferedImage img) {

    BufferedImage teste1 = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
    for (int k = 0; k < abc.length; k++) {
        int w1 = abc[k] % img.getWidth();
        int h1 = (int) Math.floor(abc[k] / img.getWidth());
        teste1.setRGB(w1, h1, 0xffffff);
    }
    return teste1;
}
4

1 回答 1

0

看一下BufferedImage 文档,上面写得很清楚:

如果坐标不在范围内,则可能会引发 ArrayOutOfBoundsException。但是,不能保证明确的边界检查。

所以你确实超出了图像的尺寸。

于 2013-07-28T13:03:39.883 回答