Symbian Learning Notes (5)--Methods for loading JPEG images

Source: Internet
Author: User

The last study was to load images from MIF and MBM files, which are generally available in the program, but with a little regret, it can only be used in SVG or BMP format, and the resources in brew or J2ME are mostly in PNG format.

If you want to use JPG or PNG images in Symbian, you need to use the classes in the multimedia ICL library that Symbian offers. One of the heavier is the Cimagedecoder class, which provides the ability to decode the image.

Let's see how to use it. Define two strings first:

_LIT(KJPEGFile,"C:\\Data\\me.jpg");
_LIT(KJPEGType,"image/jpeg");

The code used is relatively simple, as shown below

iDec = CImageDecoder::FileNewL(iRFs,KJPEGFile);

iParent->iBkImageMask=new (ELeave) CFbsBitmap();
iParent->iBkImageMask->Create( iDec-> FrameInfo().iOverallSizeInPixels,iDec-> FrameInfo().iFrameDisplayMode );
iDec->Convert( &iStatus, *(iParent->iBkImageMask) );

The IDEC is an instance of Cimagedecoder, and IRFs is an instance of RFS. And Iparent->ibkimagemask is a Cfbsbitmap object instance.

That is, we first use CIMAGEDECORDER::FILENEWL to open an image file (it will judge the image type itself, and we can provide it with the type of image we specify). The information for this image is then stored in Idec->frameinfo (), which allows you to create a Cfbsbitmap instance (because all of the images shown in Symbian are this type). Finally, invoking the Cimagedecorder asynchronous function convert converts the image (JPEG or PNG format) to a Cfbsbitmap bitmap. The only trouble is convert is an asynchronous function, the first parameter is the Trequeststatus type (can be a istatus member of an active object).

In addition to CIMAGEDECORDER::FILENEWL, there is a cimagedecorder:;D ATANEWL can also be used to construct image data from the byte content of a buffer, except that its second parameter is tdesc8& Type of Asourcedata.

Added

Don't forget to include the header file ImageConversion.h, as well as the introduction of the library Imageconversion.lib.

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.