Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Using direct screen view finder with CCamera

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Tested on Nokia N95, N95 8GB, 5800 XpressMusic
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition
S60 5th Edition
S60 3rd Edition FP2
S60 3rd Edition FP1
Keywords: CCamera, StartViewFinderDirectL
Created: User:Technical writer 1 (23 Apr 2009)
Last edited: hamishwillee (01 Aug 2012)


The direct screen view finder can be used in certain S60 devices. CCamera::StartViewFinderDirectL() will transfer view finder data from the camera to the screen using direct screen access. This improves performance and makes the code less complex, as there's no need to blit each individual view finder frame (bitmap) to the screen.


Checking if direct screen view finder is supported

After constructing the camera object with CCamera::NewL() or CCamera::New2L(), use the following code to check if direct screen view finder is supported:

 TCameraInfo info;
TBool supportsDirectVF = info.iOptionsSupported & TCameraInfo::EViewFinderDirectSupported;

Starting view finder in direct screen mode

Direct screen view finder requires the same parameters as using CDirectScreenAccess; a handle to a window server session (RWsSession), screen device (CWsScreenDevice), and a window (RWindow) to draw to. In an S60 GUI application, the first two are available from the control environment (CCoeEnv), and the window handle can be requested from a CCoeControl-derived view/container class.

 if ( supportsDirectVF )
CCoeEnv* coeEnv = CCoeEnv::Static();
iCamera->StartViewFinderDirectL( coeEnv->WsSession(),
iViewFinderRect );
else // fall back to view finder using bitmaps
iCamera->StartViewFinderBitmapsL( iViewFinderRect.Size() );

There is also an overloaded version of StartViewFinderDirectL that allows specifying a clipping rectangle in addition to the view finder display area.

Drawing the background of the view finder window

In some devices, the output of direct screen view finder will not be visible unless the background of the view finder window has been painted with a color that has a fully transparent alpha channel. In the CCoeControl::Draw() function of the container window, this can be done as follows:

 void CViewFinderView::Draw( const TRect& aRect ) const
CWindowGc& gc = SystemGc();
if ( iCamera->ViewFinderActive() )
// clear the background of viewfinder with transparent color
gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha );
gc.SetBrushColor( TRgb( 0, 0 ) );
// Draw normally when view finder is not active

Note that the direct screen view finder does not support alpha blending; view finder is visible only when the window background is fully transparent.

This page was last modified on 1 August 2012, at 04:41.
51 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.