正如Brian所说,您需要确定需要什么样的转换。
您是否要将其保存为“正常”图像文件(jpg,png等)?
如果是这样,您可能应该使用Java Image I /
O API。
如果要以“原始”格式保存,则必须指定写入字节的顺序,然后使用
IntBuffer和NIO。
作为使用ByteBuffer / IntBuffer组合的示例:
import java.nio.*;import java.net.*;class Test{ public static void main(String [] args) throws Exception // Just for simplicity! { int[] data = { 100, 200, 300, 400 }; ByteBuffer byteBuffer = ByteBuffer.allocate(data.length * 4); IntBuffer intBuffer = byteBuffer.asIntBuffer(); intBuffer.put(data); byte[] array = byteBuffer.array(); for (int i=0; i < array.length; i++) { System.out.println(i + ": " + array[i]); } }}

![如何将int []转换为byte [] 如何将int []转换为byte []](http://www.mshxw.com/aiimages/31/483265.png)
