I want to Resize and edit Pixels the bitmap frames before actual encoding get by the VREX(Video Recording example) application. I am new to Symbian even C++. I dont know in which part should I put my code either ViewFinderFrameReady or FrameBufferReady but this two are called asynchronously. If i Put it in ViewFinderFrameReady the application Close while in FrameBufferReady method nothing is happening. I dont know Why I cant make it work. Is theres a way I can know which part of my Program crashes? Pls Help.. Here my code:

void CVideoViewFinder::ViewFinderFrameReady(CFbsBitmap& aFrame)
{
// Keep backlight on while finder is active
User::ResetInactivityTime();

// Get graphics context
CWindowGc &gc = SystemGc();

// Graphics context must be activated, because we are not in Draw()
gc.Activate(Window());

// Draw finder frame to screen; BitBlt is much faster than DrawBitmap
gc.BitBlt(iFinderPosition, &aFrame);
// Deactivate graphics context
gc.Deactivate();

TSize inSize = Size();
TSize inNewSize = Size();
TUint32* bitmapData;
CFbsBitmap* iBitmap = &aFrame;
CFbsBitmap* iNewBitmap = new (ELeave) CFbsBitmap();
TRgb pixel;
inSize = iBitmap->SizeInPixels();
iNewBitmap->Create(inSize,EColor16M);
User::LeaveIfError(iNewBitmap->Duplicate(iBitmap->Handle()));
iBitmap->Resize(TSize(inSize.iHeight-48,inSize.iWidth-51));
inNewSize = iBitmap->SizeInPixels();
iBitmap->LockHeap();
bitmapData = iBitmap->DataAddress();
for ( TInt y = 0; y < inNewSize.iHeight; y++ )
{
for ( TInt x = 0; x < inNewSize.iWidth; x++ )
{
iNewBitmap->GetPixel( pixel, TPoint( x, y ) );
*bitmapData = pixel.Value();
bitmapData++;
}
}
iBitmap->UnlockHeap();
delete bitmapData;
delete iBitmap;
delete iNewBitmap;
}




void CVideoViewFinder::FrameBufferReady(MFrameBuffer* aFrameBuffer, TInt aError)
{

if (aError==KErrNone)
{
TInt i= aFrameBuffer->iIndexOfFirstFrameInBuffer;
TSize inSize = Size();
TSize inNewSize = Size();
TUint32* bitmapData;
CFbsBitmap* iBitmap = new (ELeave) CFbsBitmap();
CFbsBitmap* iNewBitmap = new (ELeave) CFbsBitmap();
TRgb pixel;

TRAPD(FrameErr,iBitmap = aFrameBuffer->FrameL(i));
if (FrameErr != KErrArgument)
{
inSize = iBitmap->SizeInPixels();
iNewBitmap->Create(inSize,EColor16M);
User::LeaveIfError(iNewBitmap->Duplicate(iBitmap->Handle()));
iBitmap->Resize(TSize(inSize.iHeight-48,inSize.iWidth-51));
inNewSize = iBitmap->SizeInPixels();
do
{
iBitmap->LockHeap();
bitmapData = iBitmap->DataAddress();

for ( TInt y = 0; y < inNewSize.iHeight; y++ )
{
for ( TInt x = 0; x < inNewSize.iWidth; x++ )
{
iNewBitmap->GetPixel( pixel, TPoint( x, y ) );
*bitmapData = pixel.Value();
bitmapData++;
}
}
iBitmap->UnlockHeap();
i++;
TRAPD(FrameErr,iBitmap = aFrameBuffer->FrameL(i));
if (FrameErr != KErrArgument)
{
User::LeaveIfError(iNewBitmap->Duplicate(iBitmap->Handle()));
iBitmap->Resize(TSize(inSize.iHeight-100,inSize.iWidth-100));
}
else
{
i=1000;
}
}while(i<1000);
}


delete bitmapData;

delete iBitmap;
delete iNewBitmap;
}

}