保存一张捕获的图像

CS000905 - Saving a captured image
保存一张捕获的图像
================================================================
 
Knowledge Base Home

ID  CS000905  Creation date  April 17, 2008
Platform  S60 3rd Edition, MR  Tested on devices  Nokia N95 8GB
Category  Symbian C++  Subcategory  Imaging, Files/Data

Keywords (APIs, classes, methods, functions):
CCamera, MCameraObserver, CCamera::CaptureImage(), MCameraObserver::ImageReady(),
 RFile::Replace(), RFile::Write()
========================================================================================
Overview
This snippet demonstrates how to save an image which was captured using the Camera API (ecam.lib).
The code is greatly simplified for the part of error handling and the actual image capturing.
For more information on capturing an image, see the related code snippet CS000904 - Capturing an image.
This snippet can be self-signed.
------------------------------------------------------------------------------------------------
概述:
这个代码片段说明如何将Camera API捕获的图片保存下来。代码极大的简化了真实图片捕获中的错误处理部分。
更多关于图片捕获的信息,参见相关代码片段---图片捕获。

===============================================================================================
MMP file
-----------------------------------------------------------------------------------
This snippet requires the following libraries:
LIBRARY  efsrv.lib
LIBRARY  eikcore.lib
--------------------------------------------------------------------------------------------------------------
In practice, however, also the following capabilities and libraries are required (to capture an image):

CAPABILITY  UserEnvironment
LIBRARY  ecam.lib
实际上,仍然也需要下面的能力和库:
======================================================================================
Source file
-----------------------------------------------------------------------------
#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
    }
========================================================================
Postconditions
The captured image is saved as C:/Data/Images/image.jpg.
捕获的图片被保存为C:/Data/Images/image.jpg
============================================================================
See also
? CS000904 - Capturing an image
? S60 Platform: Camera Example with AutoFocus Support

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值