urgent.....stuck within an infinite loop while capturing images with camera

Login to reply to this topic.
Tue, 2007-11-20 15:00
Joined: 2007-11-02
Forum posts: 37

Hi,

My code is as follows:-
There is an image encoder class to save images as follows
------------------------------------------------------------------------------------------
void CSmsEncoder::ConstructL()
{
TJpegImageData* imageData=new(ELeave)TJpegImageData;
imageData->iSampleScheme=TJpegImageData::EColor444;
imageData->iQualityFactor=KJpegQualityFactor;
iFrameImgData=CFrameImageData::NewL();
iFrameImgData->AppendImageData(imageData);
//User::LeaveIfError( iTimer.CreateLocal() ); // Initialize timer
CActiveScheduler::Add( this ); // Add to scheduler
}

void CSmsEncoder::EncodeImageToBuffer(CFbsBitmap& aBitmap, HBufC8*& aDestBuffer)
{
if(iImgEncoder!=NULL)
{
delete iImgEncoder;
iImgEncoder=NULL;
iImgEncoder=CImageEncoder::DataNewL(aDestBuffer,KJpgMime,CImageEncoder::EOptionNone);//DataNewL(aDestBuffer,KJpgMime);
iImgEncoder->Convert(&iStatus,aBitmap,iFrameImgData);
SetActive();
}
}

void CSmsEncoder::EncodeImageToFile(CFbsBitmap& aBitmap, TFileName aDestFile)
{
if(iImgEncoder!=NULL)
{
delete iImgEncoder;
iImgEncoder=NULL;
User::LeaveIfError(iFs.Connect());
CleanupClosePushL(iFs);
iImgEncoder=CImageEncoder::FileNewL(iFs,aDestFile,KJpgMime,CImageEncoder::EOptionNone);//DataNewL(aDestBuffer,KJpgMime);
iImgEncoder->Convert(&iStatus,aBitmap,iFrameImgData);
SetActive();
}
}

within the class where snaps are taken
-----------------------------------------------------------
#define KDirPictures PathInfo::ImagesPath()
#define KPhoneRootPath PathInfo::PhoneMemoryRootPath()
_LIT (KFileName2,"Snaps.jpg");

void CSnapTaker::PowerOnComplete(TInt aError)
{

CCamera::TFormat format;

TCameraInfo inff;
iCamera->CameraInfo(inff);
TInt i=inff.iNumImageSizesSupported-1;

if(inff.iImageFormatsSupported &&
CCamera::EFormatFbsBitmapColor16M)
{
format=CCamera::EFormatFbsBitmapColor16M;
}
else
{
User::Leave(KErrNotSupported);
}

iCamera->PrepareImageCaptureL(format,i);

if(inff.iOptionsSupported && inff.EViewFinderBitmapsSupported)
{
ViewFinderBitmapsL();
}
}

void CSnapTaker::ViewFinderBitmapsL()
{

TSize size;
TInt i;
TCameraInfo info;
iCamera->CameraInfo(info);
i=info.iNumImageSizesSupported-1;
if(info.iImageFormatsSupported && CCamera::EFormatFbsBitmapColor16M)
{
iCamera->EnumerateCaptureSizes(size,i,CCamera::EFormatFbsBitmapColor16M);
iCamera->StartViewFinderBitmapsL(size);
}
}

void CSnapTaker::ViewFinderFrameReady(CFbsBitmap& aFrame)
{

HandleFrame(aFrame);
iCamera->CaptureImage();

}

void CSnapTaker::HandleFrame(CFbsBitmap& aFrame)
{


iAppView->DisplayFrame(&aFrame);

if(!iFrameEncoder->IsActive())
{

iFrameBmp=new(ELeave)CFbsBitmap();
iFrameBmp->Duplicate(aFrame.Handle());
iFrameEncoder->EncodeImageToBuffer(*iFrameBmp,
iEncodedFrameToSend);

TFileName fileName(KPhoneRootPath);

fileName.Append(KDirPictures);

fileName.Append(KFileName2);//at this point value of fileName
//is--->c:/data/image/snaps.jpg

iFrameEncoder->EncodeImageToFile(*iFrameBmp,fileName);
}

}

void CSnapTaker::ImageReady(CFbsBitmap* aFrame,HBufC8* aData,TInt aError)
{

HandleFrame(*aFrame);
if(aFrame!=NULL)
{
delete aFrame;
}

}

The drawing function in appview class
----------------------------------------------------------
void CsmsAppView::DisplayFrame(CFbsBitmap* aFrame)
{
iCopyBitmap=aFrame;
DrawNow();
}

void CsmsAppView::Draw( const TRect& aRect ) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(TRgb(202,213,227));
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);


if(iCopyBitmap!=NULL)
{
TPoint pt((Rect().Width()-iCopyBitmap->SizeInPixels().iWidth)/2,
(Rect().Height()-iCopyBitmap->SizeInPixels().iHeight)/2);
gc.BitBlt(pt,iCopyBitmap);
}



}

The Infinite loop
----------------------------------------
the sequence of function calls in my program is:-
1. void CSnapTaker::PowerOnComplete(TInt aError)
2.void CSnapTaker::ViewFinderBitmapsL()
3.void CSnapTaker::ViewFinderFrameReady(CFbsBitmap& aFrame)
4.void CSnapTaker::HandleFrame(CFbsBitmap& aFrame)
5.void CsmsAppView::DisplayFrame(CFbsBitmap* aFrame)
6.void CsmsAppView::Draw( const TRect& aRect ) const
7.void CSmsEncoder::EncodeImageToBuffer(CFbsBitmap& aBitmap, HBufC8*& aDestBuffer)
8.void CSmsEncoder::EncodeImageToFile(CFbsBitmap& aBitmap, TFileName aDestFile)
9.iCamera->CaptureImage();
10.void CSnapTaker::ImageReady(CFbsBitmap* aFrame,HBufC8* aData,TInt aError)
12.void CSnapTaker::ViewFinderFrameReady(CFbsBitmap& aFrame)
13.void CSnapTaker::HandleFrame(CFbsBitmap& aFrame)
14.void CsmsAppView::DisplayFrame(CFbsBitmap* aFrame)
15.void CsmsAppView::Draw( const TRect& aRect ) const
16.void CSmsEncoder::EncodeImageToBuffer(CFbsBitmap& aBitmap, HBufC8*& aDestBuffer)
17.void CSmsEncoder::EncodeImageToFile(CFbsBitmap& aBitmap, TFileName aDestFile)
-----------------------------------
18.At this point void CSnapTaker::ViewFinderFrameReady(CFbsBitmap& aFrame) is again called (satep no 12)
and all steps from no 12 are continuously in infinite loop
-----------------------------------

Why does this happen?
How to counter this?????


Wed, 2007-11-21 06:41
Joined: 2007-11-02
Forum posts: 37
Re: urgent.....stuck within an infinite loop while capturing ima

The infinite loop terminated by use of
ICamera->StopViewFinder();

Wed, 2007-11-21 07:29
Joined: 2007-11-02
Forum posts: 37
Re: urgent.....stuck within an infinite loop while capturing ima

But there is yet another problem

I am using s60 3rd edition FP1 and N95 phone
The file location I am saving image is:-C:/data/image/snaps.jpg

In my phone:-
I am going through-
Filemanager---
Image---
and no snap is there!!!!!!!

  • Login to reply to this topic.