InputStream bais = new ByteArrayInputStream(b);
BufferedImage bImageFromConvert = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = bImageFromConvert.createGraphics();
g = cvrimg.getGraphics();
g.drawImage(bImageFromConvert, width, height, null);
ImageIO.write(bImageFromConvert, "png", new File("D:\\new.png"));
我收到以下异常:
java.lang.IllegalArgumentException: im == null!
我应该怎么办 ?
这是示例代码:
BufferedImage cvrimg = ImageIO.read(file);
int height = cvrimg.getHeight();
int width = cvrimg.getWidth();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(new_img, "jpg", baos);
baos.flush();
byte[] imageInByte = baos.toByteArray();
byte[] b = new byte[imageInByte.length];
b[i] = fromUnsignedInt(b2);
InputStream bais = new ByteArrayInputStream(b);
BufferedImage bImageFromConvert = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
// int inBytes = bais.available();
Graphics g = bImageFromConvert.createGraphics();
g = cvrimg.getGraphics();
g.drawImage(bImageFromConvert, width, height, null);
bImageFromConvert=ImageIO.read(bais);
ImageIO.write(bImageFromConvert, "png", new File("D:\\new.png"));