📄 cameraappcontroller.cpp
字号:
/*
* ============================================================================
* Name : CameraAppController.cpp
* Part of : Camera
*
* Description:
* Interface between the UI and the external modules
*
* Version:
* Copyright: Nokia Corporation, 2004
* ============================================================================
*/
#include <AknViewAppUi.h>
#include <aknsoundsystem.h>
#include <CameraApp.rsg>
#include <bautils.h>
#include <PathInfo.h>
#include "CameraAppController.h"
#include "CameraAppContainer.h"
#include "CameraCaptureEngine.h"
#include "CameraAppBaseContainer.h"
#include "CameraAppView.h"
#include "CameraAppPortraitView.h"
const TInt KCompleteImageNameMaxLength = 40;
/*
-----------------------------------------------------------------------------
CCameraAppController::CCameraAppController()
Description: C++ default constructor
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
CCameraAppController::CCameraAppController()
{
// Set the default camera mode
iCameraMode = ECameraLandscapeMode;
}
/*
-----------------------------------------------------------------------------
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;
delete iBitmapSnap;
delete iImagePath;
delete iPath;
iSoundPlayer = NULL; //Not owned by the class, prevents Lint warning
}
/*
-----------------------------------------------------------------------------
void CCameraAppController::ConstructL()
Description: Symbian OS second phase constructor
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CCameraAppController::ConstructL()
{
iFs = CEikonEnv::Static()->FsSession();
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()
{
if ( iCameraCaptureEngine )
{
delete iCameraCaptureEngine;
iCameraCaptureEngine = NULL;
}
iCameraCaptureEngine = CCameraCaptureEngine::NewL( *this );
//Create snap image
iBitmapSnap = new (ELeave) CWsBitmap( CEikonEnv::Static()->WsSession() );//faster
User::LeaveIfError( iBitmapSnap->Create( TSize(KLandscapeImageWidth, KLandscapeImageHeight), 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:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -