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"));