Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 07:31, 17 April 2008.

CS000905 - Saving a captured image

From Forum Nokia Wiki


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.

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.

See also

Related Discussions
Thread Thread Starter Forum Replies Last Post
Get a png from internet and draw it on canvas. Skarabeus Python 4 2007-01-24 13:38
Game loop question tinkezione Mobile Java General 7 2002-12-31 08:14
Camera capturing 6630 working, 6681 shows blank screen jascco Mobile Java Media (Graphics & Sounds) 2 2006-06-18 14:49
Write file in 3rd generation with j2me loay980 Mobile Java Networking & Messaging & Security 13 2006-03-30 08:03
SVG requirement for S60 msolsona Symbian Media (Graphics & Sounds) 8 2007-07-28 18:44
 
Powered by MediaWiki