/**
* Snag the pixels from an image.
*/
public static int[][] getPixels(Image image) throws IOException {
int w = image.getWidth(null);
int h = image.getHeight(null);
int pix[] = new int[w * h];
PixelGrabber grabber = new PixelGrabber(image, 0, 0, w, h, pix, 0, w);
try {
if (!grabber.grabPixels()) {
throw new IOException("Grabber returned false: " +
grabber.status());
}
} catch (InterruptedException e) {
e.printStackTrace();
}
int pixels[][] = new int[w][h];
for (int x = w; x-- > 0; ) {
for (int y = h; y-- > 0; ) {
pixels[x][y] = pix[y * w + x];
}
}
return pixels;
}
TestQuantize.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:WorldOfMoreWires
作者:
评论列表
文章目录