简体   繁体   English

从流中读取PNG文件

[英]Reading PNG file from the stream

I trying to build RDP application for android mobile.so in server side i am sending the png images with the robot class, but in client side i am not able to read that messages and print them on my android device. 我试图为Android mobile.so构建RDP应用程序,因此在服务器端我将使用机械手类发送png图像,但是在客户端我无法读取该消息并将其打印在我的android设备上。

i am using following code to read the JPEG file body data and i am able to show those images 我正在使用以下代码读取JPEG文件正文数据,并且能够显示这些图像

InputStream in = sock.getInputStream();
while(true)
{
byte[] bytes = new byte[1024*1024];
int count = 0;
do
{
count+= in.read(bytes,count,bytes.length-count);
}
while(!(count>4&&bytes[count-2]==(byte)-1 && bytes[count-1]==(byte)-39));

}

can any one help me how to read the png file out of the inputstream. 谁能帮助我如何从inputstream中读取png文件。

Try this 尝试这个

 BufferedInputStream in = new BufferedInputStream(sock.getInputStream()); 
 BufferedImage image = ImageIO.read(in);

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

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