BufferedImage与byte数组之间的转换

把一个BufferedImage图像转换为数组

 BufferedImage srcImage = ImageIO.read(new File("c:/**.jpg")); 

 byte[] data = ((DataBufferByte) srcImage.getData().getDataBuffer()).getData();

截取屏幕图片

BufferedImage srcImage = robot.createScreenCapture(rec);

 用字节数组来保存图片,保存到输出流

BufferedImage bi=ImageIO.read(new ByteArrayInputSream(byte[]); 
ImageIO.write(bufferedImage,"gif",new ByteArrayOutputStream(new byte[20000]));

你可能感兴趣的:(BufferedImage)