It is purely personal entertainment and the code is pasted out. If you have any questions or suggestions, you can leave a message. (A Friend wrote it, and transferred it to save it. If you have time to study it)
The implementation steps are as follows:
In the. h file
PRIVATE:
/**
* Createbackbufferl.
* This function is used to create double buffer bitmap resources.
*/
Void createbackbufferl ();
/**
* Releasebackbuffer.
* Function used to release Double-buffered bitmap resources.
*/
Void releasebackbuffer ();
Void drawtobackbuffer ();
// Private Members used for double buffering
PRIVATE:
Cfbsbitmap * ibackbuffer; // bitmap used in the Double Buffer
Cfbsbitmapdevice * ibackbufferdevice; // used to obtain the GC
Cfbsbitgc * ibackbuffercontext; // double buffer bitmap GC
Cfbsbitmap * ibackbuffer_2; // bitmap used in Double Buffering
Cfbsbitmapdevice * ibackbufferdevice_2; // used to obtain GC
Cfbsbitgc * ibackbuffercontext_2; // double buffer bitmap GC
In. Implementation of functions in CPP
Void cauditioncontainer: createbackbufferl ()
{
// Create back buffer bitmap
Ibackbuffer = new (eleave) cfbsbitmap;
User: leaveiferror (ibackbuffer-> Create (tsize (240,30 ),
Ieikonenv-> defaultdisplaymode ()));
// Create back buffer graphics context
Ibackbufferdevice = cfbsbitmapdevice: newl (ibackbuffer );
User: leaveiferror (ibackbufferdevice-> createcontext (ibackbuffercontext ));
Ibackbuffercontext-> setpenstyle (cgraphicscontext: esolidpen );
Ibackbuffer_2 = new (eleave) cfbsbitmap;
User: leaveiferror (ibackbuffer_2-> Create (tsize ),
Ieikonenv-> defaultdisplaymode ()));
// Create back buffer graphics context
Ibackbufferdevice_2 = cfbsbitmapdevice: newl (ibackbuffer_2 );
User: leaveiferror (ibackbufferdevice_2-> createcontext (ibackbuffercontext_2 ));
Ibackbuffercontext_2-> setpenstyle (cgraphicscontext: esolidpen );
}
Void cauditioncontainer: releasebackbuffer ()
{
// Release Double Buffering classes
If (ibackbuffercontext)
{
Delete ibackbuffercontext;
Ibackbuffercontext = NULL;
}
If (ibackbufferdevice)
{
Delete ibackbufferdevice;
Ibackbufferdevice = NULL;
}
If (ibackbuffer)
{
Delete ibackbuffer;
Ibackbuffer = NULL;
}
If (ibackbuffercontext_2)
{
Delete ibackbuffercontext_2;
Ibackbuffercontext_2 = NULL;
}
If (ibackbufferdevice_2)
{
Delete ibackbufferdevice_2;
Ibackbufferdevice_2 = NULL;
}
If (ibackbuffer_2)
{
Delete ibackbuffer_2;
Ibackbuffer_2 = NULL;
}
}
Void cauditioncontainer: drawtobackbuffer ()
{
Const cfont * font = ceikonenv: static ()-> densefont ();
Ibackbuffercontext-> usefont (font );
// _ Convert (ktext, "Hello World ");
Tbuf8 <20> msg8;
Tbuf <20> ktext;
Msg8.format (_ L8 ("Thank you for using "));
Convgbk2uni (msg8, ktext );
Ibackbuffercontext-> setpencolor (krgbgreen );
Ibackbuffercontext-> drawtext (ktext, tpoint (0, font-> heightinpixels ()));
Ibackbuffercontext_2-> usefont (font );
// _ Convert (ktext, "Hello World ");
Ibackbuffercontext_2-> setpencolor (krgbred );
Ibackbuffercontext_2-> drawtext (ktext, tpoint (0, font-> heightinpixels ()));
}
Void cauditioncontainer: Draw (const trect &/* arect */) const
{
Cwindowgc & GC = systemgc ();
GC. Clear ();
GC. bitblt (tpoint (0,100), ibackbuffer, trect (tpoint (), tsize (ibackbuffer-> sizeinpixels (). iwidth/5, ibackbuffer-> sizeinpixels (). iheight )));
GC. bitblt (tpoint (ibackbuffer_2-> sizeinpixels (). iwidth/5,100), ibackbuffer_2, trect (tpoint (ibackbuffer_2-> sizeinpixels (). iwidth/5, 0), tsize (ibackbuffer_2-> sizeinpixels (). iwidth * 4/5, ibackbuffer_2-> sizeinpixels (). iheight )));
}
Procedure
Step 1: Initialize
Add the following code before setrect of the container:
Ibackbuffer = NULL;
Ibackbufferdevice = NULL;
Ibackbuffercontext = NULL;
Ibackbuffer_2 = NULL;
Ibackbufferdevice_2 = NULL;
Ibackbuffercontext_2 = NULL;
Step 2: Add code in sizechange
Releasebackbuffer (); // releases double-buffer bitmap resources.
Createbackbufferl (); // create a double buffer bitmap Resource
Drawtobackbuffer (); // redraw double-buffer bitmap Resources
Step 3: Compile and run the program.
The image is not uploaded, and the effect is no longer displayed.
The basic idea of implementation: Write the sentence "Thank you for your use" in two font colors on two bitmaps, and splice the two images in the draw function using the bitblt function, one word, two colors. To achieve the moving effect in karaoke, you only need to change the tpoint and trect in the bitblt function through a cyclic timer. It is quite convenient.
Symbian Whampoa Forum ~~
Http://www.DevDiv.net
The power of devdiv network aggregation knowledge