Symbian: GIF Animated Image Display

Source: Internet
Author: User

Link: http://user.qzone.qq.com/463450970/blog/1220702709

 

For GIF animated images, use cimagedecoder to decode and display them. There are some instructions on the Internet. Here is some of the code I have debugged. You can play it. It's your own note.

Definition of related variables in the header file:
Tint itype;
Cimagedecoder * idecoder;
Cfbsbitmap * ibitmap;
Cfbsbitmap * ibitmapmark; // mask bitmap
Cgiftimer * igiftimer;
Ttimeintervalmicroseconds32 idisplaytimer;
Tframeinfo iframeinfo;
Tint icurframe;
Tint iframecount;
Main Code of GIF animation playback in the source file:
Void cimage: startgif ()
{
Cancel ();
Delete idecoder;
Idecoder = NULL;
Delete ibitmap;
Ibitmap = NULL;
Delete ibitmapmark;
Ibitmapmark = NULL;
This-> idecoder = cimagedecoder: filenewl (ceikonenv: static ()-> fssession (), ifilename, cimagedecoder: eallowgeneratedmask );

If (iframecount = 0)
Iframecount = This-> idecoder-> framecount (); // get the frames of GIF animated images

If (icurframe = iframecount )//After the last frame, the first frame is played again, so it is set to zero.
Icurframe = 0;
Iframeinfo = idecoder-> frameinfo (icurframe );//Get frame information

Ibitmap = new (eleave) cfbsbitmap ();

Ibitmap-> Create (iframeinfo. ioverallsizeinpixels, iframeinfo. iframedisplaymode); // note the difference between bitmap creation and mask bitmap creation.
Ibitmapmark = new (eleave) cfbsbitmap ();

Ibitmapmark-> Create (iframeinfo. ioverallsizeinpixels, egray256); // For the parameters here, the SDK provides instructions and will be used in the next statement code.
Idecoder-> convert (& istatus, * ibitmap, * ibitmapmark, icurframe); // view the SDK
Istate = edecoding;

Setactive ();
}

Void cimage: runl ()
{
If (istatus. INT () = kerrnone)
{
Istate = edecodover;
This-> iobserver. imagedecodeover (istatus. INT (); // draw an image using the observer notification
If (itype = egif)
{
Igiftimer-> startl (ttimeintervalmicroseconds32 (iframeinfo. idelay. int64 ()));//Start the timer here. Note that the latency is obtained from the frame information. I think it is best not to set the interval by yourself.
}
}
Else
User: Leave (istatus. INT ());
}

Void cimage: gifframeconverstate ()//This is a scheduled observer function, that is, the implementation of the latency settings in runl above.
{
Icurframe ++ ;//Decodes and plays the next frame.
Startgif ();
}
Void cgifappview: Draw (const trect &/* arect */) const
{
// Get the standard graphics context
Cwindowgc & GC = systemgc ();
// Gets the control's extent
Trect drawrect (rect ());
// Clears the screen
// GC. Clear (drawrect); // do not clear the screen here
GC. bitbltmasked (iimage-> getcurframetl (), iimage-> getbitmap (), rect (),
Iimage-> getbitmapmark (), efalse );
}
The above is the main functional code. It should be clear that we hope that the passing boss will not joke.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.