I worked on a project that i need to transfer GIF to the applet from server over TCP socket. The problem is that when i transfer the image it become static (the last frame displayed).
I tried to transfer (ICON) where i loaded the image on server side but it has the same result.
So, Is there any class to read animated gif so i can transfer it by ObjectOutputStream? or any way else?
Server Side:
ImageIcon icon = new ImageIcon("D:\\Data Files\\simu.gif");
Mat_out.writeObject(icon);
Client Side:
ImageIcon icon = (ImageIcon) Mat_in.readObject();
jLabel2.setIcon(icon);
createImage(..)
methods of toolkit methods of toolkit to load the image, but.. MediaTracker
to ensure the entire image is loaded before transmitting it. (This can also work for the image returned from ImageIcon
, but why create a GUI component that is not needed?) Alternately load the entire byte[]
of the image using a blocking method, and provide that to createImage(byte[])
.
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.