• About

    My name is Bayuadji, I am a plain and simple man, like good software and good code, crazy about weezer and big fans of liverpoool FC.

  • Pages

  • Categories

  • Recent Post

  • Archives

  • RSS Scrap Book

  • Advertisements

java and Animated GIF

Recently, I got a question about how to draw an animated gif using java. Drawing an image is not trivial in Java, you can use graphics.drawImage, but to draw an animated gif?

I look up in javadoc, and curious about ImageObserver, well I never use this object, and always pass a null object when drawing an image. Apperently ImageObserver object has a ImageUpdate method, so I tried when drawing animated gif, I specified and extend the ImageUpdate method.
Whoalla, the fact is when an image need to update (change the frame in animated gif), it will call imageUpdate method, so to refresh the image, the hook is in ImageObsert imageUpdate.

perhaps the code is

public void paint(Graphics g)

  public boolean imageUpdate( Image img, int flags, int x, int y,
    int w, int h )

    return true;

One Response

  1. […] na web rapidamente encontrei o seguinte post: https://inthegarage.wordpress.com/2007/02/21/java-and-animated-gif/. A solução apresentada é o uso do parâmetro ImageObserver na chamada do método […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: