Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Trusted Contributor
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified

Class cast exception EncodedImage to GifEncodedImage

[ Edited ]

Hi all,

 

I am facing this strange behaviour. This line of code that works perfectly for my colleagues is throwing error for me. I am creating an EncodedImage from GIF file and GifEncodedImage from the EncodedImage. It is throwing ClasscastExcpetion when I try to create GifEncodedImage from EncodedImage. This code works correctly for others.

 

EncodedImage encImage = GifEncodedImage.getEncodedImageResource("img/a.gif");

GifEncodedImage gifImg = (GifEncodedImage) encImage;                                    //ClassCastException

 

Jdk version 1.6.35

BB OS 5.0

 

Help of any sort is appreciated.

 

Regards,

A Y.

Trusted Contributor
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: Class cast exception EncodedImage to GifEncodedImage

Please try this code:

 

I think GifEncodeImage is a different class. So try GIFEncodedImage class.

 

EncodedImage encImage = GIFEncodedImage.getEncodedImageResource("img/a.gif");
GIFEncodedImage gifImg = (GIFEncodedImage) encImage;

 

 

Please press like, if you got your answer.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Class cast exception EncodedImage to GifEncodedImage

First thing to check is to confirm that encImage is not null.