简体   繁体   中英

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.

i am using following code to read the JPEG file body data and i am able to show those images

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.

Try this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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