0

I get a ClassCastException when trying to animate a GifImage in BlackBerry. I tried many ways, but all cause that exception. I referred to the BlackBerry knowledgecenter article "Display An Animated GIF" and I tried the following code in my mainscreen. I also tried using @swati's code from the "Animated GIF" blog post. What is my mistake?

GIFEncodedImage bitmapImage=(GIFEncodedImage)GIFEncodedImage.getEncodedImageResource("CuteCapLa4.gif");   //**Getting Exception at this line**
    AnimatedGIFField image_field=new AnimatedGIFField(bitmapImage);
    add(image_field);
Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
user1213202
  • 1,305
  • 11
  • 23
  • 1
    please check this answer http://supportforums.blackberry.com/t5/Java-Development/GIFEncodedImage-in-BlackBerry-OS7/m-p/1240501#M168911 – Eugen Martynov Sep 14 '12 at 10:30
  • thank u for your reply i also saw this link after posting the question.now my pblm is the image is displaying but animation is not working.why i dn't know – user1213202 Sep 14 '12 at 12:04
  • actually what i want is the image should blink(like hide and show) continuosly using some animation. – user1213202 Sep 14 '12 at 12:06
  • 1
    That's probably because you have now png not gif image. Png doesn't store animation as I think – Eugen Martynov Sep 14 '12 at 12:23
  • i have taken gif image only.after taking gif image only atleast iam able to display the image.using png it's not working.for gif image only animation is not coming. – user1213202 Sep 15 '12 at 03:18
  • Did you read post on dev forum? It explains that rapc converts all images to png if there is flag which is true by default for 7 OS. That's why your gif image is converted to png. – Eugen Martynov Sep 15 '12 at 16:50
  • k.Thank u For Your Suggestion.Please add Ur Post as answer.i will accept it. – user1213202 Sep 17 '12 at 11:24

1 Answers1

3

As described here:

rapc has option to convert image files to png format. However it keeps name and extension of original file. In this case you lose ability to animate as well as you get ClassCastException.

If you're using eclipse you could check this option in the Application Descriptor XML file under the "Build" submenu.

Eugen Martynov
  • 19,888
  • 10
  • 61
  • 114