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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Trusted Contributor
avi_yach
Posts: 184
Registered: ‎11-26-2010

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.

Please use plain text.
Trusted Contributor
ankitagrawal
Posts: 135
Registered: ‎02-15-2012
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.

Please use plain text.
Developer
peter_strange
Posts: 17,713
Registered: ‎07-14-2008

Re: Class cast exception EncodedImage to GifEncodedImage

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

Please use plain text.