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.