📄 cameramanager.h
字号:
/*
CameraManager. Controls cellphone camera.
This code is a derivative work of the SnapShot example
application distributed with the Symbian 6.0 SDK.
Copyright (C) 2006 Jon A. Webb
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __CAMERAMANAGER_H__
#define __CAMERAMANAGER_H__
#include <e32base.h>
#include <ecam.h>
class MMyCameraObserver;
/*!
@class CCameraManager
@discussion An instance of this manages the camera operations
*/
class CCameraManager : public MCameraObserver // public CActive,
{
private:
enum TCameraState
{
// order matters int he following. The enumerations reflect
// the process of initializing the camera
EError = -1, // Error has occured
EUninitalised, // Uninitalised
EReservingCamera, // Started reserving the camera
EStartingCamera, // Started turning the camera on
EReady, // Idle
ETakingPicture, // Busy taking a picture
ETookPicture
};
private:
// MCameraObserver overrides
/*!
@function FrameBufferReady
@discussion Not implemented
*/
void FrameBufferReady(MFrameBuffer*, TInt);
/*!
@function ImageReady
@discussion Transfers the current image from the camera to the client.
The capture is always through a CFbsBitmap so the second parameter
is not used.
@param aBitmap the captured image
@param aError error code if not successful
*/
void ImageReady(CFbsBitmap* aBitmap, HBufC8*, TInt aError);
/*!
@function PowerOnComplete
@discussion Camera power on is complete. We immediately start
the viewfinder.
@param aError error code if not successful
*/
void PowerOnComplete(TInt aError);
/*!
@function ReserveComplete
@discussion Camera reserve is complete. We immediately turn
the camera on.
@param aError error code if not successful
*/
void ReserveComplete(TInt aError);
/*!
@function ViewFinderFrameReady
@discussion View finder image is ready. We send it to the
app view to be displayed.
@param aBitmap the captured image
@param aError error code if not successful
*/
void ViewFinderFrameReady(CFbsBitmap& aFrame);
// Lifecycle
protected:
/*!
@function CCameraManager
@discussion Perform the first phase of two phase construction
@param aView the view that is to be updated
*/
CCameraManager(MMyCameraObserver& aObserver, TRect aRect);
private:
/*!
@function ConstructL
@discussion Perform the second phase construction of a CCameraManager object
*/
void ConstructL();
public:
/*!
@function NewL
@discussion Create a CCameraManager object
@param aObserver the object to be notified when a picture is taken, or an error
occurs
@result a pointer to the created instance of CCameraManager
*/
static CCameraManager* NewL(MMyCameraObserver& aObserver, TRect aRect);
/*!
@function NewLC
@discussion Create a CCameraManager object
@param aObserver the object to be notified when a picture is taken, or an error
occurs
@result a pointer to the created instance of CCameraManager
*/
static CCameraManager* NewLC(MMyCameraObserver& aObserver, TRect aRect);
/*!
@function ~CCameraManager
@discussion Destroy the object and release all memory objects
*/
virtual ~CCameraManager();
public: // Operations
/*!
@function PowerOnStartViewFinder
@discussion Power cycle the camera, then start the View Finder.
*/
void PowerOnStartViewFinder();
/*!
@function Prepare to capture an image.
@discussion The client prepares a still image capture.
*/
void PrepareCaptureImage();
/*!
@function Snap
@discussion Take a picture.
*/
void Snap();
/*!
@function StartViewFinder
@discussion Starts the View Finder.
*/
void StartViewFinder();
public: // Accessors
/*!
@function IsReady
@discussion Check if the camera is ready to take a picture.
@result ETrue if the camera is ready, otherwise EFalse
*/
TBool IsReady() const;
// Attributes
private:
/*! @var iBestFormat the image capture format */
CCamera::TFormat iBestFormat;
/*! @var iBestSizeIndex the image capture size index */
TInt iBestSizeIndex;
/*! @var iBestSize the image capture size */
TSize iBestSize;
/*! @var iBestViewfinderSize the view finder size */
TSize iBestViewfinderSize;
/*! @var iCamera the camera object */
CCamera* iCamera;
/*! @var iCameraState current state of the camera */
TCameraState iCameraState;
/*! @var iObserver the object to notify after taking a picture */
MMyCameraObserver& iObserver;
/*! @var iRect screen rectangle */
TRect iRect;
};
#endif // __CAMERAMANAGER_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -