The Source for Java Technology Collaboration

Home » java.net Forums » Mobile & Embedded » LWUIT

Thread: How to load animated gif at run time

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is not answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 5 - Last Post: Nov 4, 2009 1:51 PM by: ugochirico Threads: [ Previous | Next ]
okaminer

Posts: 38
How to load animated gif at run time
Posted: Oct 16, 2008 1:28 AM
 
  Click to reply to this thread Reply

HI this is probably very easy but I can't seem to find the code
I have bytes of animatedgif downloaded from server
How do I show the animated gif on the form
Image.CreateImage() fails

Shai Almog
Re: How to load animated gif at run time
Posted: Oct 16, 2008 4:10 AM   in response to: okaminer
  Click to reply to this thread Reply

Hi,
this is not supported by some devices which is why we offer our
animation support (via the resource editor). You will need to use the
MMAPI and the MediaComponent to "Play" an animated gif which might
not work for all devices.

> HI this is probably very easy but I can't seem to find the code
> I have bytes of animatedgif downloaded from server
> How do I show the animated gif on the form
> Image.CreateImage() fails
> [Message sent by forum member 'okaminer' (okaminer)]
>
> http://forums.java.net/jive/thread.jspa?messageID=308001
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]


okaminer

Posts: 38
Re: How to load animated gif at run time
Posted: Oct 16, 2008 10:17 AM   in response to: okaminer
 
  Click to reply to this thread Reply

Hi Shay
Thanks for reply but of course I wont to use your solution :-)
My code is as follow and for some reason it get screwed up

InputStream is = getClass().getResourceAsStream("/OceanFish.gif");
DataInputStream di = new DataInputStream(is);
StaticAnimation simage = StaticAnimation.createAnimation(di);

Do you change the animated image when creating the resource file?

Shai Almog
Re: How to load animated gif at run time
Posted: Oct 16, 2008 10:42 AM   in response to: okaminer
  Click to reply to this thread Reply

Hi,
we change the gif image when creating the resource file (decoding a
GIF is VERY CPU intensive and complex) so the code bellow won't work.
You will need to create a resource file for this to work or use MMAPI.

On Oct 16, 2008, at 7:17 PM, lwuit-users@mobileandembedded.org wrote:

> Hi Shay
> Thanks for reply but of course I wont to use your solution :-)
> My code is as follow and for some reason it get screwed up
>
> InputStream is = getClass().getResourceAsStream("/OceanFish.gif");
> DataInputStream di = new DataInputStream(is);
> StaticAnimation simage = StaticAnimation.createAnimation(di);
>
> Do you change the animated image when creating the resource file?
> [Message sent by forum member 'okaminer' (okaminer)]
>
> http://forums.java.net/jive/thread.jspa?messageID=308270
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]


ugochirico

Posts: 3
Re: How to load animated gif at run time
Posted: Nov 4, 2009 1:51 PM   in response to: okaminer
 
  Click to reply to this thread Reply

Hi,
I wrote a class by which you can show in an LWUIT component an animated gif, loaded from an input stream, as an animation, like you tried to do in your code.
Also, you can start and stop the animation and set the related loop counter.

In this post I published a brief explanation of my work and the source code:
http://ugochirico.blogspot.com/2009/11/animated-gif-using-lwuit.html

Regards,
Ugo Chirico
http://www.ugosweb.com
http://www.cryptware.it

okaminer

Posts: 38
Re: How to load animated gif at run time
Posted: Oct 17, 2008 8:37 AM   in response to: okaminer
 
  Click to reply to this thread Reply

Thanks
Resource file it will be




 XML java.net RSS