Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Animated GIF images on a form

 
Zac Styris
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All

I'm having trouble appending a animated GIF image on to a J2ME form,the image displays but it doesn't animate, does anyone know why and a method to make this work ? The code i used is stated below

img =Image.createImage("/download.gif");
item = new ImageItem(null,img,item.LAYOUT_CENTER,null);
f1.append(item);


Thanks
[ February 03, 2006: Message edited by: Zac Styris ]
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

First of all J2ME formally allows only .PNG image files (the .GIF etc are not supported).

So to create an animated "gif" you need to create several png images and then move between them in another thread.

Look at this example:

press here
 
Zac Styris
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, i'll try that out.
 
Seetesh Hindlekar
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this program work?

Variables not define : imgIndex

Declaring int imgIndex = 0 or 1; doesnt work at all. Maybe the declaration of this variable has to be figured out.

Replaced the name MyCanvas with GIFCanvas creating GIFCanvas.java in the process.

This program throws java.lang.NullPointerException:

at GIFCanvas.paint(+23)
at javax.microedition.lcdui.Canvas.callPaint(+80)
at javax.microedition.lcdui.Display.repaint(+77)
at javax.microedition.lcdui.Display.registerNewCurrent(+237)
at javax.microedition.lcdui.Display.access$400(+6)
at javax.microedition.lcdui.Display$DisplayAccessor.foregroundNotify(+46)
at javax.microedition.lcdui.Display$DisplayManagerImpl.notifyWantsForeground(+152)
at javax.microedition.lcdui.Display$DisplayManagerImpl.access$100(+6)
at javax.microedition.lcdui.Display.setCurrentImpl(+115)
at javax.microedition.lcdui.Display.setCurrent(+29)
at GIFDemo.startApp(+24)
at javax.microedition.midlet.MIDletProxy.startApp(+7)
at com.sun.midp.midlet.Scheduler.schedule(+270)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+116)


Rgds,

Seetesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic