What I learned last time was to load images from the MIF and MBM files. Generally, this method can be used for all the images in the program, but with a little regret, it can only use the SVG or BMP format, most of the resources in brew or j2s are in PNG format.
If you want to use jpg or PNG images in Symbian, you need to use the class in the multimedia ICL library provided by Symbian. The cimagedecoder class is the most important one, providing the function of decoding images.
Let's see how to use it. Define two strings first:
_ Partition (kmeanfile, "C: // data // me.jpg ");
_ Partition (k1_type, "image/JPEG ");
The code used is relatively simple, as shown below:
IDEC = cimagedecoder: filenewl (IRFS, k1_file );
Iparent-> ibkimagemask = new (eleave) cfbsbitmap ();
Iparent-> ibkimagemask-> Create (IDEC-> frameinfo (). ioverallsizeinpixels, IDEC-> frameinfo (). iframedisplaymode );
IDEC-> convert (& istatus, * (iparent-> ibkimagemask ));
Here, IDEC is the cimagedecoder instance, while IRFS is The RFS instance. Iparent-> ibkimagemask is a cfbsbitmap object instance.
That is to say, we first use cimagedecorder: filenewl to open an image file (it will determine the image type by itself, and we can also provide it with the specified image type ). Then the information of this image is saved in IDEC-> frameinfo (). You can use this information to create a cfbsbitmap instance (because all the images displayed in Symbian are of this type ). Finally, call the asynchronous function convert of cimagedecorder to convert an image (in JPEG or PNG format) to a cfbsbitmap bitmap. The only trouble is that convert is an asynchronous function. The first parameter is the trequeststatus type (it can be an istatus member of an active object ).
In addition to cimagedecorder: filenewl, A cimagedecorder:; datanewl can also be used to construct image data from bytes in a buffer zone, but its second parameter is tdesc8 & type asourcedata.
[Supplement]
Do not forget to include the header file imageconversion. H, and imageconversion. Lib.