简体   繁体   English

byte []到bufferedImage的转换为null

[英]byte[] to bufferedImage conversion gives null

I am trying to convert byte[] array to buffered image so than i can resize the image..but problem is conversion always turned into null.here is my code.. 我试图将byte []数组转换为缓冲的图像,以便我可以调整图像的大小。但是问题是转换总是变成null。这是我的代码。

 ByteArrayInputStream bais = new ByteArrayInputStream(user.getUser_image());
 //Here user.getUser_image() returns byte[] returned from server..
 try {
      BufferedImage image = ImageIO.read(bais);
      System.out.println("============><================"+image);//Here it prints null
      BufferedImage scaledImage = Scalr.resize(image,48);
 }
 .....and so on

It means that the ImageIO class is not able to select an appropriate ImageReader. 这意味着ImageIO类无法选择适当的ImageReader。 The purpose of this could be corrupted byte array or unsupported image type. 这样做的目的可能是损坏的字节数组或不支持的图像类型。 Try to debug it. 尝试调试它。

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

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