Classification: |
C++ |
Category: |
Graphics |
Created: |
07/24/2000 |
Modified: |
07/11/2001 |
Number: |
FAQ-0505 |
Platform: |
ER5, Symbian OS v6.0, Symbian OS v6.1 |
|
Question: I'm writing a window Anim DLL and I want to copy part of the windows content into a bitmap, so that later on I can redraw
it back again.
Answer: You will need to create a bitmap and a bitmap device and a gc which is activated on the bitmap, which is all straight forward.
Then you will need to use one of the following 2 functions to get a copy of the screen: void CFbsBitGc::BitBlt(const TPoint& aPoint,const CFbsBitGc& aGc); void CFbsBitGc::BitBlt(const TPoint& aPoint,const CFbsBitGc& aGc,const TRect& aSourceRect);The first one does not give you any control over which part of the screen that you can copy, so it is probably best to use
the 2nd one. The 1st parameter is the position in your bitmap that you want the part of the screen to go. The 2nd one is a
screen gc, you can create one of these using the screen device available from the function: iFunctions->ScreenDevice(), except you will need to cast away the const'ness. The 3rd parameter is the rectangle on the screen that you want to copy.
If you want to copy the entire content of the window that you are an Anim over then you will need to get the client side to
tell you where it is. There is a function that can tell you the size of your window, but not one for the location: iFunctions->WindowSize() (or for post ER5 code iWindowFunctions->WindowSize()). Thus your code might look something like this:
TSize size=iFunctions->WindowSize(); //Ask the Anim the size of your window iBitmap=new(ELeave) CFbsBitmap(); //Create a bitmap to store the window content User::LeaveIfError(iBitmap->Create(size,EGray4)); //ditto iBitmapDevice=CFbsBitmapDevice::NewL(iBitmap); //Create a bitmap device so we can draw to the bitmap iBitmapGc=CFbsBitGc::NewL(); //Create a GC to draw to the bitmap iBitmapGc->Activate(iBitmapDevice); //Active it on the bitmap we just created CFbsBitGc* gc; User::LeaveIfError(CONST_CAST(CFbsScreenDevice*,iFunctions->ScreenDevice())->CreateContext(gc)); //Create a screen gc iBitmapGc->BitBlt(TPoint(0,0),*gc,TRect(iWindowTopLeft,size)); //Copy the window content
|