×
Namespaces

Variants
Actions

保存捕获的图片

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

兼容于
平台: S60 3rd Edition, MR
S60 3rd Edition (initial release)

文章
翻译:
最后由 hamishwillee 在 30 May 2013 编辑
  • 详细描述

这里演示了如何保存用Camera API(ecam.lib)捕捉的图片。下列代码很大程度简化了对错误和实际图片捕捉的处理。更多关于捕捉图片的内容,请参考CS000904 - Capturing an image


这段代码可以自签名使用。


MMP

代码需要下列库

LIBRARY  efsrv.lib 
LIBRARY eikcore.lib

特别注意,如果要捕捉图片需要下列能力和链接库

CAPABILITY  UserEnvironment
LIBRARY ecam.lib


源文件

#include <EIKENV.H>  // CEikonEnv/**
* Symbian Onboard Camera API observer. Gets called after
* CCamera::CaptureImage() is called.
* @param aBitmap a pointer to a bitmap image if this was the format specified
* @param aData a pointer to JPEG image data if this was the format specified
* @param aError KErrNone on success or an error code on failure
*/
void CCameraEngine::ImageReady(CFbsBitmap* aBitmap, HBufC8* aData, TInt aError)
{
// TODO: Error handling
 
// It is assumed here that before capturing the image format was set
// to CCamera::EFormatExif, and that the device supports this format.
// This means that the (EXIF JPEG) image data is contained in aData
// argument.
 
// Connect to the file server session and reserve a file for the image
RFs& fsSession = CEikonEnv::Static()->FsSession();
_LIT(KFilename, "C:\\Data\\Images\\image.jpg");
RFile file;
TInt frErr = file.Replace(fsSession, KFilename, EFileWrite);
// TODO: Error handling
 
// Write the image data to the file.
TInt fwErr = file.Write(*aData);
// TODO: Error handling
}


运行条件

捕捉的图片被存放在C:\Data\Images\image.jpg

This page was last modified on 30 May 2013, at 07:04.
63 page views in the last 30 days.
×