Java - get pixel array from image

后端 未结 7 1199
面向向阳花
面向向阳花 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:28

    If useful, try this:

    BufferedImage imgBuffer = ImageIO.read(new File("c:\\image.bmp"));
    
    byte[] pixels = (byte[])imgBuffer.getRaster().getDataElements(0, 0, imgBuffer.getWidth(), imgBuffer.getHeight(), null);
    

提交回复
热议问题