×
Namespaces

Variants
Actions
Revision as of 07:41, 1 August 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Using direct screen view finder with CCamera

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

Description

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.

Solution

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;
iCamera->CameraInfo(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(),
*(coeEnv->ScreenDevice()),
*iAppView->DrawableWindow(),
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 ) );
gc.Clear();
return;
}
 
// 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 07:41.
61 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.

×