Generating Animated GIF in java is it possible

Hi,
I have worked on generating GIF / JPG Files in java. Now that i would like to know if its possible to create animated GIF in java. I have'nt got any examples on that. If anyone has any, can you pl post them here?

This is an animated gif encoder : http://jmge.net/java/gifenc/
Animated GIF Example :
import net.jmge.gif.Gif89Encoder;
void writeAnimatedGIF(Image[] still_images,
String annotation,
boolean looped,
double frames_per_second,
OutputStream out) throws IOException
Gif89Encoder gifenc = new Gif89Encoder();
for (int i = 0; i < still_images.length; )
gifenc.addFrame(still_images);
gifenc.setComments(annotation);
gifenc.setLoopCount(looped ? 0 : 1);
gifenc.setUniformDelay((int) Math.round(100 / frames_per_second));
gifenc.encode(out);

Similar Messages

  • Animated Gif Repaint

    I knew I was going to end up here eventually, stupid animated gifs.
    First of all, I get weird drawing artifacts on an animated gif on jkd 1.5, I upped this to 1.6 and everything is cool with displaying the gif. It could be because I'm running JBuilder in a XP VM. I don't really care how to fix this, or if its even fixable, I'm just pointing it out.
    I have an animated gif in an imageicon. The program is hangman, and the gif shows a stick figure walking up onto the podium to get hung. I would like to play the gif once, every time the "New Game" button is clicked. I have tried a variety of things to do so, including JLabel1.repaint(); calling the label again, etc, etc. I'll try to post the relevant bits of my code.
    public class HangFrame
        extends JFrame implements ActionListener {
      public HangFrame()
        try {
          jbInit();
        catch (Exception ex) {
          ex.printStackTrace();
      }jbinit calls the placement of all the items.
        jLabel1.setBounds(new Rectangle(19, 57, 550, 400));
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == start) {
          start();
    ....'start' is my name for the button that reads "New Game".
    The start method contains:
    ImageIcon maingif = new ImageIcon( (ClassLoader.getSystemResource(
            "hang1.gif")));
         jLabel1.setIcon(maingif);
    //I've been trying different stuff right here, like repaint.The image displays correctly, and runs once (per the setting I gave it in flash, or thats how java does it).
    I've searched extensively (seems I got lucky by just managing to get it to display once :D). I saw that I might have to flush the image or something like that, but I'm not really sure what that means. I've never had any experience with the graphics and paint component, most of the work we do in class is console and algorithm stuff. I got bored over break and made my hangman into a swing app. I'd appreciate any help.
    Oh, and sorry if this should be in the swing subforum, I figured my issue was too basic for it.
    Edited by: rpk5000 on Dec 31, 2007 8:52 AM

    rpk5000 wrote:
    This is where you're wrong. Dipshits like you post **** like this all the time when it's readily available information that can be searched for WITHOUT >hosing up our forums.Great, give me a link, or even a search term to use on google or these forums. Before you give me search terms, you might want to actually check and make sure the answer is somewhere there...are you out of your freakin mind?!?!?!
    go to google and type "java gif animation"
    you think you're the first person to want to do this?!?!
    moreover, search the forums here
    you think you're the first person to ask for this here?!?!
    You would think "repainting an imageicon animated gif java" would give a page that has the answer on it within the first 10 results but....
    I'm looking for a page that simply says, take your imageicon and call.... (repaint();) or whatever to make it run one more time.Did you even read the API for ImageIcon! It took me 2 seconds to find the information for animating gifs as imageicons.
    Well Java just sucks now doesn't it. Stop using animated gifs and Java since they suck. There, problem solved!I like Java a lot, I'm just saying, in certain instances it seems to fall short.No, YOU fall short. I found the solution in 3 seconds.
    This is a "New to Java" subforum, if you can't handle helping people in a pleasant manner, that shows you respect the other person, what do you think people will think of you and java. If I spent more time on forums like this, and was looking at which language to try, I doubt I would pick java.I don't care what you think of me OR Java. I'm tired of noobs wasting forum resources with this crap. Once I was new to everything, but I went to the library and when the internet came along i learned how to search it!
    Critical thinking people. Don't we teach this in schools any more?!
    When it becomes an Internet joke (http://thedailywtf.com/Articles/plz-email-me-teh-codez.aspx) about how bad the sun forums are, well, you really need to reconsider what you want to do with your life.
    LMAO! You are the daily WTF!
    Edited by: wpafbuser1 on Dec 31, 2007 1:52 PM

  • Animated gif moving to fast

    I am trying to display an animated gif in a JLabel. My problem is that for some reason the animated gif speeds through the frames, instead of moving at the speed it was created at. Any idea what might be causing it.
    Below is the code I'm using to display the animated gif.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.JDialog;
    import java.io.*;
    public class loadingScreen extends JDialog
         private JLabel loadingLabel;
         ImageIcon loadIcon = new ImageIcon("images/animated_loading.gif");
        This function makes the loadingScreen a dialog box which, when
        opened, limits the user to be only able to use this window until
        they close it.
         public boolean startLoadingScreen()
              Window owner = (Window) getParent();
              Dimension d = getSize();
              Rectangle r = owner.getBounds();
              int x = r.x + r.width/2;
              int y = r.y + r.height/2;
              setBounds(x, y, d.width, d.height);
              getCenter();
              setVisible(true);
              return true;
        This function is called by an outside program. It takes in the owner
        frame information. It takes in a string that will be the title of
        the dialog box.
         public loadingScreen(Frame owner,String title,boolean modality)     
              super(owner, title, modality);          
              displayWindow();
        This function makes the gui for the window
         public void displayWindow()
              setResizable(false);
              Box groupBox = Box.createVerticalBox();
              loadingLabel = new JLabel(loadIcon);
              groupBox.add(loadingLabel);
              Container dialogPane = getContentPane();
              dialogPane.setLayout( new FlowLayout() );
              dialogPane.add(groupBox);
              pack();
         private void getCenter()
              Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
              Rectangle frame = getBounds();
              setLocation((screen.width - frame.width)/2,(screen.height - frame.height)/2);
    }

    Thanks for the help. Once I editied the gif file everything worked fine. As a side note, I used Gimp to edit the file and when I tried saving it had a funny message. "Delay inserted to prevent evil CPU-sucking anim."
    Thanks for the help.
    Ricky

  • Using animated gif...

    I've encountered a problem in displaying animated gif using java Swing.
    For my program, I need to display 6 animated gif images. Sometimes I would get all those displayed, but sometimes only 1 or few are displayed.
    This problem troubles me until I found that it is the problem of animated gif I've used, because I have tried to replace the animated gif to static ones then every time the images are all displayed.
    I need a help urgently. Thanks a lot in advance.

    Hi
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    public class Dance extends JFrame 
    public Dance()  
         addWindowListener(new WindowAdapter()
        {     public void windowClosing(WindowEvent ev)
              {     dispose();
                   System.exit(0);}});
         getContentPane().setLayout(null);
         setBounds(10,10,400,300);
         JLabel j1 = new JLabel(new ImageIcon("cut1.gif"));
         j1.setBounds(10,30,40,40);
         getContentPane().add(j1);
         JLabel j2 = new JLabel(new ImageIcon("cut2.gif"));
         j2.setBounds(50,70,40,40);
         getContentPane().add(j2);
         JLabel j3 = new JLabel(new ImageIcon("cut3.gif"));
         j3.setBounds(90,110,40,40);
         getContentPane().add(j3);
         JLabel j4 = new JLabel(new ImageIcon("cut4.gif"));
         j4.setBounds(130,150,40,40);
         getContentPane().add(j4);
         setVisible(true);
    public static void main (String[] args)
         new Dance();
      Noah

  • Need help importing animated gif by ImageIcon in Japplet

    Hello. Im new to Java, but I want to import this animated gif with Java in a Japplet using ImageIcon, but it does not work and I would really appreciate if anyone could help me with this.
    import java.applet.*;                                   
    import java.awt.*;   
    import java.net.*;
         public class Bilder extends Japplet{                               
         public ImageIcon(java.net."http://pixelninja.se/kappawin.gif");
      Image[] bild = new Image[1];                            
      int nr=0;                                                
      public void init(){                                     
        setBackground(Color.black);                         
        bild[0] = getImage(getCodeBase(),"4a.gif");     
      public void paint(Graphics g){
        g.drawImage(bild[0],50,50,212,282,this);
    }

    You cant do animated gifs this way.
    Also you should remember that you cannot load images in to an applet if it is hosted somewere else than the host that hosts the applet.
    Esiast way to display an image icon with a animated gif will be creating a Image Label and adding it to the applet.
    Ex:-
    public class MyImageApplet extends JApplet{
       public void init(){
          getConentPane().setLayout(new BorderLayout());
           URL imageURL = getClass().getResource("/myImage.gif"); 
          // Above image file should be in the code base or in the archive file of the applet
          getConentPane().add(new JLabel(new ImageIcon(imageURL)));
    }

  • Transparent Animated Gif not possible anymore in Keynote 09?

    I have created an animated GIF (a series of transparent GIFs) with Adobe Image Ready, which was showing and playing OK on keynote 2.0.2. I have tried the same animated GIF on 5.0, and it seems the transparency of GIF is gone, it plays OK though. It would appear silly to lose this feature on later keynotes.
    Any ideas why Keynote 5.0 does show the GIF without the transparency?
    Any ideas are appreciated!
    -AstroGrad

    You just need transparency in your file. Not sure if it has to be pre-multiplied. In graphic converter you need to remove the backgrounds. Haven't used GC in years so can't say how you can be sure it's gone but in Photoshop, Illustrator and After Effects you can choose to have a checkerboard background to tell you when you are seeing 'thru' the image and by how much (the overall opacity or mask of the whole image if that doesn't confuse the issue).
    If you are using PS images they will almost certainly generated with a set of rectangles including a perimeter cropping box and white background and these need to go either before it's bitmapped in a vector base app or the relevant pixels erased after it has been bit mapped in GC. As previously mentioned, if you have a unique bkgd colour, colour selecting/keying are some ways to do this). Much faster for >10 images to generate the plots without the bkgd but this may not be possible, what software is source material coming from?
    I regularly bring in vector based moving art-work into keynote with alpha from Adobe AE, Apple Quartz and rendered .mov files. Some codecs (H.264) don't support a separate alpha channel (RGBA) but PNG (slow to render) and animation and a bunch of others do. Pre-multiplying removes the A channel in the RGBA (by multiplying the R/G/B by the A values) thereby speeding and making compatible with some GPUs/render pipelines.

  • Is it possible to create an animated GIF with transparency in AME?

    I have Adobe Media Encoder CS5.5 with Windows 7.  Is it possible to save a video (I saved it as uncompressed AVI from After Effects) as an animated GIF with transparency in it (eg. black=transparent)?
    I also have VirtualDub 1.9.11 but don't see a transparency option in that.
    It's for the web where I'd like the normal web background to show in the black (ie. should be transparent) parts of the GIF.

    Thanks.  But if I wanted to keep using it it costs about £600 to buy.  Would Adobe Photoshop Elements 11 be able to do this too (also, seeing as there is an animated gif creation option in AME and used to be in AE, couldn't they just add a checkbox etc. for AME/and AE for doing transparent gifs in those if they don't support it?  Since transparency is a standard feature of .GIF is seems strange to allow GIF creation but not allow transparency)?

  • Is it possible to create an animated gif with a different hotspot/link on each state?

    Hi! I was unable to find the answer to my question by searching, so sorry if this has been discussed already.
    I'm trying to make an animated gif that's basically a little slideshow with a different link on each slide (or state, as Fireworks calls them). But it only seems to let me use one hotspot for the whole thing, even if I insert in the layer instead of in the state. I tried using slices instead of hotspots, and it does the same thing.
    Is it possible?

    Ok, thanks! I have another way to do what I'm trying to do, I just thought it might be better to do it this way. Obviously I was wrong!
    Thanks again!

  • Animated gif - is it possible stop & start ?

    OS 10.4.11 - GL/CS
    I have a series of animated gifs on my website and I like the simplicity of the animation. Is it possible to have a stop and go feature (button) - see http://www.artdesign.org.uk/graphicpages/webdesign.html. I do not wish to create a Flash and a slide show would seem to not allow for auto run.

    The Super Slide pause/play button involves several actions. The first is Super  Slide Pause, then you set a Condition with Super Slide If that involves  Set Image URL with true and false settings. It sounds complicated, but once you get the hang of it it becomes easy. Having said that, I always have to refer back to the instructions or active web pages to get it right.
    Do you have DaverJ's tutorial for the Slideshow? It would be beneficial to review his instructions along with the screen caps. Here is a link to one of my pages that uses the slideshow with the pause/play button active. The images have to load in cache before the slideshow begins, the the pause/play is active.
    http://www.redshift.com/~lorac/jhjfashion.html
    Here a four screen shots in sequence for the settings. Hope this helps.
    Carol
    SupreSlidePause action
    SuperSlide Condition
    The True settings.... uses the play image
    The False settings.... uses the pause image

  • Possible to Use Animated GIF as Rollover Image?

    Before I spend a lot of time on development...does anyone
    know if it's possible to use an animated GIF as a rollover image in
    Captivate? I'm developing an e-Learning course for a
    Sarbannes-Oxley application, and I want to be able to hover over an
    object, then have a rollover graphic describe the hover target in
    more detail...the catch being that I want the description to look
    like a scrolling stock ticker.
    I'm sure Flash is probably the ideal development environment
    for this idea, but that project is way beyond my Flash skills at
    this point...
    Thanks!

    I know you can load and display a PNG image just the way you do for a GIF/JPEG one :
    ImageIcon myIcon = new ImageIcon("my_icon.png");but I don't think many others formats are recognized by j2se... you can simply try to load a BMP file to find out.

  • Is it possible and how to open animated gif files in Photoshop CS4

    I made a Google search and I found tips that Photoshop can open frames from animated gif files by using File->Import->Video Frames to Layers. But this menu is missing from Photoshop CS4 on the computer I'm using it. Searching this forum for "Import animated gif" didn't return any result. Any ideas?

    Zeno
    curt y, sorry for the late reply, I tried that but I doesn't work. I have to choose at least two files in the Load Layers window in order for the OK button to be available and then some action script uses the different files to make layers and merges them but not from the frames of the gif file. I can undo through the script to see what it did but it never accessed the frames of the gif file, just the first frame. Choosing "make frames from layers" in the animation palette only puts the original files into layers - that is only the first frame of the gif file.
    I guess I'm out of luck with the 64  bit version of Photoshop as Zeno suggested :-(
    What program would you people suggest for opening each frame from gif files?

  • Animated GIF not cycling frames in Tomcat

    I have pages that use animated gif files to get across a point.
    In the IDE, they cycle the images as they should
    SunAppserver cycles them properly.
    I only get the first frame in Tomcat (5.5.7)
    Over on the java.net, I saw this on a page concerning JAI:
    GIF
    The decoder supports animated GIF files and GIF files with transparent background. Only the first frame of an animated GIF file may be loaded via JAI; subsequent frames must be obtained via direct use of the ancillary codec classes.
    Um, am I missing something, or is this a Tomcat problem ?

    You just need transparency in your file. Not sure if it has to be pre-multiplied. In graphic converter you need to remove the backgrounds. Haven't used GC in years so can't say how you can be sure it's gone but in Photoshop, Illustrator and After Effects you can choose to have a checkerboard background to tell you when you are seeing 'thru' the image and by how much (the overall opacity or mask of the whole image if that doesn't confuse the issue).
    If you are using PS images they will almost certainly generated with a set of rectangles including a perimeter cropping box and white background and these need to go either before it's bitmapped in a vector base app or the relevant pixels erased after it has been bit mapped in GC. As previously mentioned, if you have a unique bkgd colour, colour selecting/keying are some ways to do this). Much faster for >10 images to generate the plots without the bkgd but this may not be possible, what software is source material coming from?
    I regularly bring in vector based moving art-work into keynote with alpha from Adobe AE, Apple Quartz and rendered .mov files. Some codecs (H.264) don't support a separate alpha channel (RGBA) but PNG (slow to render) and animation and a bunch of others do. Pre-multiplying removes the A channel in the RGBA (by multiplying the R/G/B by the A values) thereby speeding and making compatible with some GPUs/render pipelines.

  • Animated GIF problem saving for web in CS6

    I made an animated gif in CS6 and trying to save it for the web. The duration of the animation is pretty long, about 44 seconds. After 17 seconds the animation stops while the saving was completed. How can I solve this problem? The file is too large to attach (725 x 225 px) unfortunately.
    Please give me some advice;-)

    Yopu probably exceed the GIF specs and generate too many frames.
    How many frames are possible?

  • Animated GIF files in forms

    Is it possible to display an animated GIF file on a form that
    plays once and then stops and if so HOW???!!!!!
    null

    Mr. Dave Taulty
    It is possible to use a animated gif in forms(6)
    there is native control called "Bean area", there is special
    java class to do that. all you need to specify is the
    implementation class of the Bean Area
    native "Bean Area" control is the answer to your query
    Vishnu V.
    null

  • Add animated gif to JFrame toolbar in place of default coffee cup

    Hi,
    I am sorry if someone has already asked this question. I have searched the forums but only found aswers relating to adding static images to replace the default coffee cup. Is it possible to replace this image with an animated gif? When I add an animated gif with the following code:
    URL imageUrl = myProgram.class.getResource("image.gif");
    ImageIcon icon = new ImageIcon(imageUrl);
    JFrame frame = new myProgramFrame();
    frame.setIconImage(icon.getImage());
    I am loading the image from an executable jar.
    The program fails to load (but produces no errors).
    Thank you for any help you can offer.

    Hmmm ... intrestin, I've just modified a *.gif file of my own to make the icon animated and 'java MyProgram' just hangs at the command line -so, I guess you're stuffed with it. I can't think of a workaround either, sorry

Maybe you are looking for

  • Windows Vista 64 bit service error on iCloud

    I am running Vista 64 bit and trying to log into iCloud and everytime I do I get this message "You can't sign in because of server error" anyone got any ideas?

  • Connecting MacBook to Sony Bravia LCD tv

    I really want to connect my MacBook to our tv to play region 1 dvd's and videos I've bought in iTunes. At the Apple Store they sold me 3 cables, 1 Mini-DVI to DVI connector, 1 DVI to HDMI cable and a cable for sound. I've got these both hooked up to

  • Map loader not recognizing phone

    Hi everybody; I have a new N95, updated all the software and have used maps at least once. Well, exactly once. After updating I went out and found a free WLAN and loaded the local map. Now back at my computer the map loader software says no medium de

  • Song order goes backwards

    Hello! So when I click on an album, the song order starts from where i tap and goes to the track BEFORE. I have the latest iPod touch and the latest iTunes. I just backed up my iPod and then restored my backup before this happened. Now its happening.

  • How do I transfer data to my mac from a portable hard drive without getting error 36?

    I keep getting error 36 when I try to transfer data from my portable hard drive it says unable to read file :-(