【发布时间】:2013-11-08 19:06:59
【问题描述】:
目前我想获得一个包含图像像素的数组。我现在正在使用此代码:
int[] pixels;
int width = firstfloorimg.getWidth();
int height = firstfloorimg.getHeight();
firstfloorimg.getRGB(0, 0, width, height, pixels, 0, width);
但是,当我想使用像素数组时,它会给出 NullpointerException。我以前用过这段代码没有错误。
为什么会发生这种情况,我该如何进行这项工作?
【问题讨论】:
-
pixels没有初始化,你刚刚声明了它。
标签: java arrays image nullpointerexception