简体   繁体   English

如何在java中将java.awt.Image转换为字节数组?

[英]How to convert java.awt.Image to byte arrays in java?

I have the java.awt.Image object and I want to convert it into bytes array that contain RGB value of each pixel. 我有java.awt.Image对象,我想将其转换为包含每个像素RGB值的bytes数组。 For example, 例如,

byte[][][] image_color = new byte[3][image.getWidth()][image.getHeight()];

Big Thanks 太谢谢了

Check the overloads of java.awt.image.BufferedImage.getRGB() , or the methods of java.awt.image.Raster , which can be obtained through BufferredImage.getRaster() . 检查java.awt.image.BufferedImage.getRGB()的重载或java.awt.image.Raster的方法,这些方法可以通过BufferredImage.getRaster()获得。 You can find some sample usage here . 您可以在此处找到一些示例用法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM