I would like to previwe video before snapshot using the snapshot example.
I would like to start preview video immediatly after I start the program and snapshot after use use menu item "take picture" and stop.
I found the topic in "Series 60 1.0 : connect to the camera and display the video" very interesting, except no exact clue after success, does any one can provide a little more final code here? thanks a lot. I have problem to call SnapLow(iBitmap) in CCameraManager::RunL(), and also I dont know where to call it in AppUI class as mentioned by the author.
TBool CCameraManager::IsReady() { if (iCameraState == EReady)/// otherwise it does not draw! { return ETrue; } else { return EFalse; } }
TBool CCameraManager::IsPreview() { if (iCameraState == EDisplayVideo)/// otherwise it does not draw! { return ETrue; } else { return EFalse; } }
void CCameraManager::Snap(CFbsBitmap& aBitmap) { //iCameraServer.SetImageQuality(RCameraServ::EQualityHigh);// use low quality first iCameraServer.GetImage(iStatus, aBitmap); SetActive(); } ////////////////////////////////////////////////////////////////
void CCameraManager::SnapLow(CFbsBitmap& aBitmap) { ASSERT(IsReady());// must be ready then call it! the it is not EReady anymore but EDisplayvideo iCameraState=EDisplayVideo; iCameraServer.SetImageQuality(RCameraServ::EQualityLow); iCameraServer.GetImage(iStatus,aBitmap); SetActive();
}
Anything more?.... oh this must be added: void CAppView::Draw(const TRect& /*aRect*/) const { TBool DugMsg = ETrue;
ASSERT(iCameraManager != NULL);
// Clear the screen CWindowGc& gc = SystemGc(); gc.UseFont(NEikonEnvironment::EikEnv().AnnotationFont());
gc.Clear(Rect()); if ( (iCameraManager->IsReady()||iCameraManager->IsPreview()) && (iBitmap->Handle()) )///add preview option otherwise it does not draw! { // gc.DrawBitmap(Rect(), iBitmap, iBitmap->SizeInPixels());//this produce flicking effect. gc.BitBlt(TPoint(8,10), iBitmap);/// this does not produce flicking effect
In somewhere of the posted problem this flickring proble was mentioned and here is the solution...
TBool IsSnap is in CCameraManager...
Did I already give the complete code? if you miss anything that's the part you need to study and pls be kind enough to add some more line for others when you success, it has been half year and I can obviously miss something...
Forum posts: 2
I solved it and forget to put answer back
add sth here:
class MCameraObserver
{
virtual void PictureTaken() = 0;
virtual void SnapPreview() = 0;
virtual void Snap() =0;...
and correspondingly :
void CAppView::Snap()
{
ASSERT(iCameraManager != NULL);
iCameraManager->Snap(*iBitmap);
}
void CAppView::SnapPreview()
{
ASSERT(iCameraManager != NULL);
iCameraManager->SnapLow(*iBitmap);
}
Key changes here:
void CCameraManager::RunL()
{
if (iStatus != KErrNone)
{
iObserver.Error(iStatus.Int());
return;
}
switch (iCameraState)
{
case EStartingCamera:
iCameraServer.SetLightingConditions(RCameraServ::ELightingNormal);
iCameraServer.SetImageQuality(RCameraServ::EQualityLow);
iCameraState = EReady;
iObserver.SnapPreview();//start preview from begining
break;
case EDisplayVideo:
iObserver.PictureTaken();
iCameraState = EReady;
iObserver.SnapPreview();
if(IsSnap) iCameraState = ETakingPicture;
break;
case ETakingPicture:
iObserver.Snap();//maybe not show!
iCameraState = EReady;
break;
case EReady:
iObserver.PictureTaken();
break;
case EError:
default:
iCameraState = EError; // For the invalid cases
iObserver.Error(KErrGeneral);
}
}
You need to chage this part according to your application:
void CCameraManager::ConstructL()
{
User::LeaveIfError(iCameraServer.Connect());
iCameraState = EStartingCamera;
iCameraServer.TurnCameraOn(iStatus);
CActiveScheduler::Add(this);
SetActive();
IsSnap = EFalse;
}
TBool CCameraManager::IsReady()
{
if (iCameraState == EReady)/// otherwise it does not draw!
{
return ETrue;
}
else
{
return EFalse;
}
}
TBool CCameraManager::IsPreview()
{
if (iCameraState == EDisplayVideo)/// otherwise it does not draw!
{
return ETrue;
}
else
{
return EFalse;
}
}
void CCameraManager::Snap(CFbsBitmap& aBitmap)
{
//iCameraServer.SetImageQuality(RCameraServ::EQualityHigh);// use low quality first
iCameraServer.GetImage(iStatus, aBitmap);
SetActive();
}
////////////////////////////////////////////////////////////////
void CCameraManager::SnapLow(CFbsBitmap& aBitmap)
{
ASSERT(IsReady());// must be ready then call it! the it is not EReady anymore but EDisplayvideo
iCameraState=EDisplayVideo;
iCameraServer.SetImageQuality(RCameraServ::EQualityLow);
iCameraServer.GetImage(iStatus,aBitmap);
SetActive();
}
Anything more?.... oh this must be added:
void CAppView::Draw(const TRect& /*aRect*/) const
{
TBool DugMsg = ETrue;
ASSERT(iCameraManager != NULL);
// Clear the screen
CWindowGc& gc = SystemGc();
gc.UseFont(NEikonEnvironment::EikEnv().AnnotationFont());
gc.Clear(Rect());
if ( (iCameraManager->IsReady()||iCameraManager->IsPreview()) && (iBitmap->Handle()) )///add preview option otherwise it does not draw!
{
// gc.DrawBitmap(Rect(), iBitmap, iBitmap->SizeInPixels());//this produce flicking effect.
gc.BitBlt(TPoint(8,10), iBitmap);/// this does not produce flicking effect
In somewhere of the posted problem this flickring proble was mentioned and here is the solution...
TBool IsSnap is in CCameraManager...
Did I already give the complete code? if you miss anything that's the part you need to study and pls be kind enough to add some more line for others when you success, it has been half year and I can obviously miss something...
Good luck Linda