java - 将图像从 android 串行发送到 java 应用程序时出错 -javax.imageio.IIOException : Bogus Huffman table definition

标签 java android image arrays huffman-code

我需要将图像从 android 应用程序发送到 java 应用程序。基本上,我需要图像中的一个字节数组发送到传输的 rf 模块。另一个 rf 模块接收字节数组并将其发送到必须制作图像的 java 应用程序。

安卓代码:

FileInputStream fis = new FileInputStream(myFile);
    byte[] b=new byte[(int)myFile.length()];        
    fis.read(b);server.send(b);

Java代码:

FileOutputStream fwrite = new FileOutputStream(new File("my_xml"),true);
                                fwrite.write(bb);//bb is a byte from rf using input stream as soon as a byte comes it is read to file. This is necessary for some other reasons
                                fwrite.flush();
                                fwrite.close();

获取完整文件后:

FileInputStream fir=new FileInputStream("my_xml");
        final BufferedImage bufferedImage = ImageIO.read(fir);
        ImageIO.write(bufferedImage, "bmp", new File("image.bmp"));
        fir.close();

我收到错误 javax.imageio.IIOException: Bogus Huffman 表定义 rf 工作正常,因为文本文件正在完美发送。请帮助。即使没有 ImageIo 代码,即使在将扩展名更改为 jpeg 后也不会提供图像

最佳答案

该错误表示由于格式错误而无法读取图像文件。即某些字节丢失或错误或位置不正确,因此无法解码文件。我的 rf 传输没有像 tcp/ip 这样的协议(protocol),因此由于通信 channel 错误导致一些字节丢失,因此出现错误。

关于java - 将图像从 android 串行发送到 java 应用程序时出错 -javax.imageio.IIOException : Bogus Huffman table definition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12245922/

相关文章:

java - mahout 中 GenericRecommenderIRStatsEvaluator 的非法精度?

java - java中子类对象到父类(super class)的显式类型转换

java - 菜单项显示不正确

android - AsyncTask get() 有时会卡住

android - 如何翻译字符串数组中的项目?

image - 为什么我的自定义交付图像没有缓存在浏览器中?

Java - 使用 runtime.getRuntime().exec 运行 Excel

java - Android 文件选择器中的 FileNotFoundException

azure - 如何在不同区域使用Azure VM Image

image - ASIHttpRequest上传图片