Java - get pixel array from image

后端 未结 7 1069
面向向阳花
面向向阳花 2020-11-22 03:52

I\'m looking for the fastest way to get pixel data (int the form int[][]) from a BufferedImage. My goal is to be able to address pixel (x, y) from

7条回答
  •  长发绾君心
    2020-11-22 04:23

    Something like this?

    int[][] pixels = new int[w][h];
    
    for( int i = 0; i < w; i++ )
        for( int j = 0; j < h; j++ )
            pixels[i][j] = img.getRGB( i, j );
    

提交回复
热议问题