[sc1.0-cvs] CVS update: /sip-communicator-1-0-draft/src/net/java/sip/communicator/impl/gui/main/utils/

yanas at dev.java.net yanas at dev.java.net
Thu Feb 23 16:42:15 CET 2006


User: yanas   
Date: 2006/02/23 07:42:15

Log:
 animated gif image reading added

File Changes:

Directory: /sip-communicator-1-0-draft/src/net/java/sip/communicator/impl/gui/main/utils/
=========================================================================================

File [changed]: ImageLoader.java
Url: https://sip-communicator-1-0-draft.dev.java.net/source/browse/sip-communicator-1-0-draft/src/net/java/sip/communicator/impl/gui/main/utils/ImageLoader.java?r1=1.5&r2=1.6
Delta lines:  +49 -0
--------------------
--- ImageLoader.java	21 Feb 2006 17:16:54 -0000	1.5
+++ ImageLoader.java	23 Feb 2006 15:42:13 -0000	1.6
@@ -9,10 +9,16 @@
 
 import java.awt.Image;
 import java.awt.image.BufferedImage;
+import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ArrayList;
+import java.util.Iterator;
 
 import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
 
 import net.java.sip.communicator.util.Logger;
 
@@ -471,6 +477,49 @@
 		return image;
 	}
 
+    /**
+     * Loads animated gif image.
+     */
+    
+    public static BufferedImage[] getAnimatedImage(ImageID imageID){
+        
+        String path = Images.getString(imageID.getId());
+        
+        URL  url = ImageLoader.class.getClassLoader()
+                        .getResource(path);
+        
+        Iterator readers = ImageIO.getImageReadersBySuffix("gif");
+        
+        ImageReader reader = (ImageReader) readers.next();
+              
+        ImageInputStream iis;
+        
+        BufferedImage[] images = null;
+        
+        try {
+            iis = ImageIO.createImageInputStream(url.openStream());
+            
+            reader.setInput(iis);
+            
+            final int numImages;
+            
+            numImages = reader.getNumImages(true);
+            
+            images = new BufferedImage[numImages];
+                       
+            for(int i=0; i<numImages; ++i) {
+                images[i] =  reader.read(i);            
+            }
+            
+        } catch (IOException e) {
+            log.error("Failed to load image:" + path, e);
+        } finally {
+            log.logExit();
+        }
+
+        return images;
+    }
+    
 	/**
 	 *  Represents the Image Identifier.
 	 */




---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe at sip-communicator-1-0-draft.dev.java.net
For additional commands, e-mail: cvs-help at sip-communicator-1-0-draft.dev.java.net





More information about the commits mailing list