Using direct screen view finder with CCamera
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:
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();
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.