我正在尝试从串口读取数据并将其转换为图片。代码构建但没有显示任何内容。有没有人看到我遗失的任何明显事物?
int len = 0;
while ( ( data = in.read()) > -1 )
{
if ( data == '\n' ) {
break;
}
buffer[len++] = (byte) data;
}
InputStream inPic = new ByteArrayInputStream(buffer);
BufferedImage img = ImageIO.read(inPic);
Graphics img1 = img.createGraphics();
img1.drawImage(img, 0, 0,null);