📄 cameraappcontroller.cpp
字号:
/*
* ============================================================================
* Name : CCameraAppController from CameraAppController.cpp
* Part of : CameraApp
* Created : 05/06/2006 by Forum Nokia
* Version : 2.0
* Copyright: Nokia Corporation, 2006
* ============================================================================
*/
#include <AknViewAppUi.h>
#include <CameraApp.rsg>
#include <bautils.h>
#include <PathInfo.h>
#include "CameraAppController.h"
#include "CameraAppContainer.h"
#include "CameraAppBaseContainer.h"
#include "CameraAppView.h"
#include "CameraAppPortraitView.h"
#include "CameraAppAppUi.h"
// If you have a 3rd Edition device that provides support for the newer mixin
// classes MCameraObserver2 and MCameraBuffer, you can include and use
// CameraCaptureEngine_3rd_Ed.h instead of CameraCaptureEngine.h. Please note,
// however, that the CameraCaptureEngine_3rd_Ed implementation is only a
// sample and has not been tested yet. Thus it might not work properly
// without modifications.
//#include "CameraCaptureEngine_3rd_Ed.h"
#include "CameraCaptureEngine.h"
// Constants
const TInt KCompleteImageNameMaxLength = 40;
const TInt KFileNameIndexMaxLength = 5;
_LIT(KCameraInUse, "Camera in use by another app.");
_LIT(KSnapSoundFile, "Camera1a_2_8kHz.wav");
// For 2nd Edition emulator only
#ifdef __WINS__
_LIT(KEmulatorPath, "c:\\system\\Apps\\cameraapp\\");
#endif
/*
-----------------------------------------------------------------------------
CCameraAppController::CCameraAppController()
Description: C++ default constructor
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
CCameraAppController::CCameraAppController(CAknViewAppUi& aAppUi)
:iAppUi(aAppUi),
iCameraMode(ECameraLandscapeMode),
iSoundPlayerReady(EFalse)
{
}
/*
-----------------------------------------------------------------------------
void CCameraAppController::PowerOff()
Description: powers off the camera
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CCameraAppController::PowerOff()
{
iCameraCaptureEngine->PowerOff();
}
/*
-----------------------------------------------------------------------------
CCameraAppController::~CCameraAppController()
Description: destructor, free allocated resources
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
CCameraAppController::~CCameraAppController()
{
// Power off the camera
PowerOff();
if ( iCameraCaptureEngine )
delete iCameraCaptureEngine;
if (iBitmapSnap)
delete iBitmapSnap;
if (iImagePath)
delete iImagePath;
if (iPath)
delete iPath;
if (iSoundPlayer)
{
iSoundPlayer->Close();
delete iSoundPlayer;
}
}
/*
-----------------------------------------------------------------------------
void CCameraAppController::ConstructL()
Description: Symbian OS second phase constructor
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CCameraAppController::ConstructL()
{
iEikEnv = CEikonEnv::Static();
iPath = new(ELeave) TFileName;
// Create the sound player here
CreateSoundPlayerL();
TFileName path = PathInfo::PhoneMemoryRootPath(); //Default
path.Append( PathInfo::ImagesPath() );
iImagePath = HBufC::NewL( path.Length() );
iImagePath->Des().Copy( path );
}
/*
-----------------------------------------------------------------------------
TCameraState CCameraAppController::CameraMode() const
Description: gets the camera mode
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
TCameraState CCameraAppController::CameraMode() const
{
return iCameraMode;
}
/*
-----------------------------------------------------------------------------
void CCameraAppController::SetCameraMode(TCameraState aCameraMode)
Description: Set the camera display mode
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CCameraAppController::SetCameraMode(TCameraState aCameraMode)
{
iCameraMode = aCameraMode;
}
/*
-----------------------------------------------------------------------------
TDisplayMode CCameraAppController::DisplayMode() const
Description: Returns default display mode
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
TDisplayMode CCameraAppController::DisplayMode() const
{
return iCameraCaptureEngine->DisplayMode();
}
/*
-----------------------------------------------------------------------------
void CCameraAppController::InitializeCameraL()
Description: Initialize still image capture engine
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CCameraAppController::InitializeCameraL(const TRect& aRect)
{
if (!iCameraCaptureEngine)
{
iCameraCaptureEngine = CCameraCaptureEngine::NewL( *this, aRect );
//Create snap image
iBitmapSnap = new (ELeave) CWsBitmap(iEikEnv->WsSession());
User::LeaveIfError( iBitmapSnap->Create(aRect.Size(), DisplayMode()));
}
}
/*
-----------------------------------------------------------------------------
void CCameraAppController::ReleaseCamera()
Description: releases a reserved camera
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CCameraAppController::ReleaseCamera()
{
iCameraCaptureEngine->ReleaseCamera();
}
/*
-----------------------------------------------------------------------------
void CCameraAppController::StartViewFinderL()
Description: Starts the view finding operation
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CCameraAppController::StartViewFinderL()
{
iCameraCaptureEngine->SetMode( iCameraMode );
iCameraCaptureEngine->StartViewFinderL();
}
/*
-----------------------------------------------------------------------------
void CCameraAppController::SetAppContainer(CCoeControl* aAppContainer,
TCameraViewIds aViewId)
Description: Gives reference to Active view container to Controller
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CCameraAppController::SetAppContainer( CCoeControl* aAppContainer,
TCameraViewIds aViewId)
{
iContainer = aAppContainer;
iActiveView = aViewId;
}
/*
-----------------------------------------------------------------------------
const TDesC& CCameraAppController::ImagePath() const
Description: Returns the complete path of the saved image
Comments :
Return values: Returns the complete path of the saved image
-----------------------------------------------------------------------------
*/
const TDesC& CCameraAppController::ImagePath() const
{
return *iImagePath;
}
/*
-----------------------------------------------------------------------------
const TDesC& CCameraAppController::ImagePath() const
Description: Set the actual bitmap size
Comments :
Return values:
-----------------------------------------------------------------------------
*/
void CCameraAppController::SetActualVFSize( const TSize& /*aSize*/ )
{
if ( iContainer )
{
(STATIC_CAST(CCameraAppContainer*,iContainer))->
ReDrawOffScreenBitmap( );
}
}
/*
-----------------------------------------------------------------------------
void CCameraAppController::ViewFinding( CFbsBitmap& aFrame )
Description: Gets image from image capture engine, and displays it on
screen, called by the capture engine to display the bitmap
Comments :
Return values:
-----------------------------------------------------------------------------
*/
void CCameraAppController::ViewFinding( CFbsBitmap& aFrame )
{
if ( iContainer )
{
(STATIC_CAST(CCameraAppBaseContainer*,iContainer))->
DrawImageNow( aFrame );
}
}
/*
-----------------------------------------------------------------------------
void CCameraAppController::StopViewFinder()
Description: Stops view finding
Comments :
Return values:
-----------------------------------------------------------------------------
*/
void CCameraAppController::StopViewFinder()
{
iCameraCaptureEngine->StopViewFinder();
}
/*
-----------------------------------------------------------------------------
void CCameraAppController::SnapL()
Description: Gets the snapped image from Camera driver
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CCameraAppController::SnapL()
{
iCameraCaptureEngine->SnapL();
}
/*
-----------------------------------------------------------------------------
CFbsBitmap& CCameraAppController::GetSnappedImage()
Description: Gives snapped image to be displayed in PostExposure view
Comments :
Return values: Snapped CFbsBitmap object reference
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -