In Symbian, bitmap is generally loaded. You can generate an MBM file, and then display the bitmap by loading bitmap!
There are two ways to create a. MBM file: one is to automatically create the file during compilation, or you can use the bmconv tool to manually create the file.
1. Create
You mustProgramTo add the following content to the MPs file:
Start bitmap target-File
[Targetpath target-path]
[Header]
[Sourcepath source-path]
Source color-depth source-Bitmap-list
End
For example:
Start bitmap ogginco. MBM
Header
Targetpath/system/apps/Ogg
Sourcepath ../bitmaps
Source C12 ogg.bmp
End
Target-file is the name of the generated MBM file.
Targetpath is optional. If not specified, the MBM file is generated in the application directory.
Header is also optional. If this keyword is specified, A. mbg header file is generated in the epoc32/include directory. The generated. mbg header file contains the enumerated values of each bitmap. The enumerated values generated in this file are required in the resource file. In this example, embmoggincoogg is generated.
Sourcepath specifies the location of the original windows BMP file.
Source All BMP files after the statement must be of the same color depth. To include BMP files with different colors in a separate MBM file, you must specify multiple sources.
2. Create with bmconv Tool
Run the following command:
Bmconv sprites. MBM/c12ship.bmp/c12bullet.bmp/c12alien.bmp
After running the bmconv command, use the/u option to extract the BMP file from the MBM file. The color depth of the BMP file is 24. You can also specify the/V option after the command to display the content of the MBM file. Enter bmconv in the command line to view all options it supports.
The. in the H file, give it an enumeration ID number, which is generated in the system folder (epoc32include ). bitmap files can be accessed using their ID numbers in the MBM file. Each ID adopts the following format to construct embm <MBM File Name> <Bitmap File Name>, such as embmoggincoogg.
You can use the following method to display bitmap files:
Cfbsbitmap * ibitmap;
Void ctestguiappview: constructl (const trect & arect)
{
.....
Ibitmap = loadmybitmapl ();
}
Cfbsbitmap * ctestguiappview: loadmybitmapl ()
{
_ Partition (kmbmfilename, "// system // apps // Ogg // ogginco. MBM ");
Tfilename APP = ceikonenv: static ()-> eikappui ()-> application ()-> appfullname ();
Tparseptr Parser (APP );
Tfilename mbmfile = parser. Drive ();
Mbmfile. append (kmbmfilename );
Cfbsbitmap * ibgbmp = new (eleave) cfbsbitmap ();
User: leaveiferror (ibgbmp-> load (mbmfile, embmoggincoogg ));
Return ibgbmp;
}
Void ctestguiappview: Draw (const trect &/* arect */) const
{
......
GC. bitblt (tpoint (10, 10), ibitmap );
}
Finally, do not forget to add the # includ file lib file and delete ibitmap In The Destructor;
1. Get the MBM file name
If the MBM file is stored in the application directory:
If you have the same name as your application, you can use the following method to obtain it:
Tfilename mbmfile = ceikonenv: static ()-> eikappui ()-> application ()-> bitmapstorename ();
If you have different names, you can define only the file name and then use the following method to complete the path name:
# Include <aknutils. h> // For completewithapppath ()
_ Partition (kmbmfilename, "images. MBM ");
Tfilename mbmfile = completewithapppath (mbmfile );
If it is not in the same directory, you can obtain the file name of the application using the following method. You can find the drive letter from the beginning, and add your own defined path and file name.
Tfilename appfile = ceikonenv: static ()-> eikappui ()-> application ()-> appfullname ();
2. Load bitmap
In addition to the bitmap load () method, you can also use the following method:
Cfbsbitmap * bitmap = ceikonenv: static ()-> createbitmapl (mbmfile, embmhelloworldimage1 );
The advantage is that you do not need to create a cfbsbitmap object.