In the previous post we've developed the RBitmapBuffer buffer class that holds a bitmap buffer (sources are available at the end of this post).
Now we'll use this class in a simple Symbian UI application.
It can be tied to the Symbian applications in a many ways but we'll see the one that goes for "Hello World" sample provided with Carbide.c++ IDE.
So start the Carbide.c++ (I use the version 1.3). Create new project (File -> New -> Symbian OS C++ Project). Select the "3-rd Feature Ed. GUI Application".
The IDE will create the project with a list of items. The file of interest for us is a "..AppView.cpp" because it defines the behavior of ..AppView class that has an access to the screen.
Besides that file we, of course, need some others that establish the connections inside the program logic.
The "BitmapBuffer" and "BufferRenderer" sources are available at the end of this post.
The ".." is the name of your project.
First let's go to the "..AppView.h" file.
We will add a new property to the ..AppView class. This property would be: CBufferRenderer* iBufferRenderer;
It would store the image buffer and will be able to render it (draw on it).
To simplify the code we will make iBufferRenderer as public, for anyone can access it and draw something on it.
We'll also add one new method to the ..AppView class to output the buffer.
That is shown below (the file: "..AppView.cpp"):
Listing 2.
/**
* Function will draw the image
*
*/
void ..AppView::DrawImage(CWindowGc& aGc) const
{
CFbsBitmap* bitmap = iBufferRenderer->getBitmapBuffer() ;
TSize size ( bitmap->SizeInPixels() ) ;
Now, let's draw the rectangle on the phone screen when the user selects the 'Message' button from the options menu.
To do that, we will go to the "..AppUi.cpp" file and append the HandleCommandL() method with the code below: