Convert jpeg/png to an array of pixels in java

前提是你 提交于 2019-12-06 14:42:57

It turns out you need commons-fileupload. Look at the user guide for how to obtain the image InputStream. From there you can simply call:

BufferedImage image = ImageIO.read(item.getInputStream());

From here on there are many ways:

  • loop over the image dimensions and for each x and y call int rgb = image.getRGB(x, y);
  • same as above, but call getRed(x, y), getGreen(x, y), getBlue(x, y)
  • get the ColorModel and call the above methods there
  • call getRGB(startX, startY, w, h, rgbArray, offset, scansize)
  • call getData(), which returns a Raster, and call getPixes(..) there

Use PixelGraber. It returns one-dimensional array of RGB data.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!