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
Developer
Posts: 264
Registered: ‎06-04-2009
My Device: Not Specified
Accepted Solution

GIF animation problem

Hi

 

I am using a GIF image for drawing the loading bar

The image is a black & white gif image i.e its black image with white animation on it. but problem is when i tried to load the image during the encodedImage its having corruption when the fading effect is  shown. I have tried the the implementation with animation thread. Also I tried by drawing the image in a class which extends BitMapField. still  the problem persists. Any idea on such an issue

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

Re: GIF animation problem

Can you describe the problem in detail you see when you use the gif Animation from the Knowledgebase again.  Does it look like the image is not being updated correctly?

 

I have had problems using that with certain gifs and have reworked to suit.  This seems to depend on the type of gif.  In other words, the standard code works for some gifs, my changed code works for others.  I presume if you had an animation editor you could look at the various gifs and figure out the difference and probably the reason. 

Developer
Posts: 264
Registered: ‎06-04-2009
My Device: Not Specified

Re: GIF animation problem

yes

when i use the implementation given in the knowledge base the image is not coming properly it looks like corrupted. for the same code other gifs were working properly.

I have also tried changing the extension to bin .If u have any workaround can u share it . Is there any standard encoding formats for these images which will work in blackberry

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

Re: GIF animation problem

This is the code I had to use for some gifs:

 

Standard paint:

 

    protected void paint(Graphics graphics)
    {
        //Call super.paint. This will draw the first background 
        //frame and handle any required focus drawing.
        super.paint(graphics);

        //Don't redraw the background if this is the first frame.
        if (_currentFrame != 0)
        {
            //Draw the animation frame.
            graphics.drawImage(_image.getFrameLeft(_currentFrame), _image.getFrameTop(_currentFrame),
                _image.getFrameWidth(_currentFrame), _image.getFrameHeight(_currentFrame), _image, _currentFrame, 0, 0);
        }
    }

 

The paint I used:

 

    protected void paint(Graphics graphics)
    {
        for ( int i = 0; i <= _currentFrame; i ++ ) {
            graphics.drawImage(_image.getFrameLeft(i),
                               _image.getFrameTop(i),
                               _image.getFrameWidth(i),
                               _image.getFrameHeight(i),
                               _image,
                               i,
                               0, 0);
        }
    }

 

 

 

New Contributor
Posts: 7
Registered: ‎12-14-2011
My Device: 2010 - Bold
My Carrier: Vodafone In

Re: GIF animation problem

I have tried the solution given at 

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800345/...

 

to rotate the GIF image in progress dialog. But it'll gives an effect like the rotation of image get stopped for few milliseconds whenever the painting of the last frame of an image get completed

 

Your solution has solved above mention issue. But it seems that this might have some performance issue because graphics.drawImage() will be called n! times. Is there any way to rotate the GIF image by calling graphics.drawImage for just n times (n = total number of frames in GIF image)?