⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cameraappcontroller.cpp

📁 SYMBIAN camera 样例程序如果需要了解更多或缺少什么文件可以邮件联系我
💻 CPP
📖 第 1 页 / 共 2 页
字号:

	void CCameraAppController::SnapL()

	Description: Gets the snapped image from Camera driver
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppController::SnapL()
    {
    iCameraCaptureEngine->SnapL();
    }

/*
-----------------------------------------------------------------------------

	CFbsBitmap& CCameraAppController::GetSnappedImage() 

	Description: Gives snapped image to be displayed in PostExposure view
	Comments   :

    Return values: Snapped CFbsBitmap object reference

-----------------------------------------------------------------------------
*/
CFbsBitmap& CCameraAppController::GetSnappedImage() 
    {
    return *iBitmapSnap;
    }

/*
-----------------------------------------------------------------------------

	void CCameraAppController::SaveImageL()

	Description: Saves the snapped image on disk
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppController::SaveImageL()
    {    
    // Get the next usable file name
    GetNextUsableFileName();

    // Save the image
    iCameraCaptureEngine->SaveImageL( QualityFactor(), &iNewFileName, 
        &(iEikEnv->FsSession()) );
    }

/*
-----------------------------------------------------------------------------

	TJpegQualityFactor CCameraAppController::QualityFactor() const

	Description: Returns current quality factor
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
TJpegQualityFactor CCameraAppController::QualityFactor() const
    {
    return KHighQualityFactor; 
    }

/*
-----------------------------------------------------------------------------

	void CCameraAppController::CreateSoundPlayerL()

	Description: Initializes snap sound player
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppController::CreateSoundPlayerL()
    {
    #ifdef __SERIES60_3X__    
        // Only in 3rd Edition. The snap sound file can be found 
        // in \private\<UID3>\ folder.
        RFs& fs = iEikEnv->FsSession();
        User::LeaveIfError( fs.CreatePrivatePath( EDriveC ) );
        User::LeaveIfError( fs.SetSessionToPrivate( EDriveC ) );
        User::LeaveIfError( fs.PrivatePath(iSoundFilePath) );
    #else
        #ifndef __WINS__  // don't save settings to z-drive in emulator
        // In 2nd Ed device the snap sound file will be in 
        // \system\apps\cameraapp\ folder.
        TFileName appFullName = (iAppUi.Application())->AppFullName();
        TParsePtr appPath(appFullName);
        iSoundFilePath = appPath.DriveAndPath();
        #else 
        // For 2nd Ed emulator
        iSoundFilePath.Append(KEmulatorPath);
        #endif //__WINS__
    #endif
        
      iSoundPlayer = CMdaAudioPlayerUtility::NewL(
        *this, EMdaPriorityMin, EMdaPriorityPreferenceNone);
    }

/*
-----------------------------------------------------------------------------

	void CCameraAppController::PlaySnapSound( )

	Description: Plays snap sound
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppController::PlaySound( TInt aSoundId )
    {
    TFileName soundFile(iSoundFilePath);
    
    switch(aSoundId)
        {
        case ESoundIdSnap:
            soundFile.Append(KSnapSoundFile);
            break;
        case ESoundIdFocused:
            soundFile.Append(KFocusedSoundFile);
            break;
        default:
            return;
        }
        
    TRAPD(ignore, iSoundPlayer->OpenFileL(soundFile));
    }

/*
-----------------------------------------------------------------------------

	void CCameraAppController::ShowConversionStatusL( const TDesC &aStatus )

	Description: show the status of the current image converting status

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppController::ShowConversionStatusL( const TDesC &aStatus, 
                                                  TBool aShowFileName )
    {
    if( !iContainer )
        return;
        
    CCameraAppBaseContainer* baseCon = 
        static_cast<CCameraAppBaseContainer*>( iContainer );
    
    // append filename in parenthesis if requested
    if(aShowFileName)
        {
        TParsePtrC parse(iNewFileName);        
        HBufC* format = HBufC::NewLC( aStatus.Length() 
                                      + KImageFileName().Length()
                                      + 8 );
                                      
        TBuf<16> nameBuf(parse.Name());
        format->Des().Format(_L("%S (%S)"), &aStatus, &nameBuf);
        baseCon->ShowConversionStatusL( format->Des() );
        CleanupStack::PopAndDestroy(); // format
        return;
        }

    // else, just display the status message
    baseCon->ShowConversionStatusL( aStatus );        
    }

/*
-----------------------------------------------------------------------------

	TBool CCameraAppController::IsImageConversionInProgress()

	Description: return to status showing whether the image conversion is 
				 in progress or not.
	omments   :

    Return values: true if image is being converted

-----------------------------------------------------------------------------
*/
TBool CCameraAppController::IsImageConversionInProgress()
    {
    return iCameraCaptureEngine->IsImageConversionInProgress();		
    }

/*
-----------------------------------------------------------------------------

	void CCameraAppController::RedrawNaviPaneL()

	Description: redraw navi tabs, showing "Standard" and "Portrait"
	omments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppController::RedrawNaviPaneL()
    {
    if ( iContainer )
        {
        CCameraAppAppUi* appUi = STATIC_CAST(CCameraAppAppUi*, &iAppUi);
        (STATIC_CAST(CCameraAppBaseContainer*, iContainer))->
            RedrawNaviPaneL(appUi->GetDecoratedTabGroup());
        }

    if ( iCameraCaptureEngine )
        {
        iCameraCaptureEngine->SetEngineState( EEngineIdle );
        }
    }

/*
-----------------------------------------------------------------------------

	TEngineState CCameraAppController::GetEngineState()

	Description: get engine state
	omments   :

    Return values: engine state

-----------------------------------------------------------------------------
*/
TEngineState CCameraAppController::GetEngineState()
    {
    return iCameraCaptureEngine->GetEngineState();
    }

/*
-----------------------------------------------------------------------------

	TEngineState CCameraAppController::GetEngineState()

	Description: set engine state
	omments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppController::SetEngineState( TEngineState aState )
    {
    iCameraCaptureEngine->SetEngineState( aState );
    }

/*
-----------------------------------------------------------------------------

	void CCameraAppController::GetNextUsableFileName()

	Description: get the next usable file name
	omments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppController::GetNextUsableFileName()
    {	
    TInt index = 0;

    do {
        iNewFileName.Copy( iImagePath->Des() );
        iNewFileName.Append( KImageFileName );

        TBuf<KFileNameIndexMaxLength> num;
        num.Num( index );
        iNewFileName.Append( num );
        
        iNewFileName.Append( KJpgFileExtension );
        if ( !BaflUtils::FileExists( iEikEnv->FsSession(),
            iNewFileName ) )
            break;

        index ++;
        } while ( 1 );
    }

/*
-----------------------------------------------------------------------------

	void CCameraAppController::HandleError(TInt aError)
	
	Description: handle to error messages from the capture engine
	omments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppController::HandleError(TInt aError)
    {
    switch( aError )
        {
        case KErrNone:
            break;
            
        case KErrInUse:
            // Since the camera is in use, we need to display a message, 
            // showing the message "Camera in use by another application"
            if ( iContainer )
                STATIC_CAST(CCameraAppBaseContainer*, iContainer)->
                ShowErrorMessage( KCameraInUse );
            break;
            
        case KErrHardwareNotAvailable:
        
            if ( iContainer )
                STATIC_CAST(CCameraAppBaseContainer*, iContainer)->
                ShowErrorMessage( KNoCamera );
            break;
                        
        case KErrExtensionNotSupported:  // used when AF is not supported                        
            break;
        }
    }

/*
-----------------------------------------------------------------------------

	TBool CCameraAppController::IsCameraUsedByAnotherApp()
	
	Description: return whether the camera is being used another app.
	Comments   : 

    Return values: true if it is used by another app.

-----------------------------------------------------------------------------
*/
TBool CCameraAppController::IsCameraUsedByAnotherApp()
    {
    // return true if camera engine is not yet constructed
    if( !iCameraCaptureEngine )
      return ETrue;
      
    return iCameraCaptureEngine->IsCameraUsedByAnotherApp();
    }

/*
-----------------------------------------------------------------------------

	TInt CCameraAppController::SetZoomL(TBool aEnable)
	
	Description: Set the zoom factor. It will increase or decrease the zoom 
				 factor
	Comments   : 

    Return values: zoom factor of the camera

-----------------------------------------------------------------------------
*/
TInt CCameraAppController::SetZoomL(TBool aEnable)
    {
    return iCameraCaptureEngine->SetZoomFactorL( aEnable );
    }


/*
-----------------------------------------------------------------------------

	TInt CCameraAppController::StartFocusL()

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppController::StartFocusL()
    {
    iCameraCaptureEngine->StartFocusL();
    }
    

/*
-----------------------------------------------------------------------------

	TInt CCameraAppController::StartFocusL()

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppController::FocusCancel()
    {
    iCameraCaptureEngine->FocusCancel();
    }


/*
-----------------------------------------------------------------------------

    void CCameraAppController::MapcInitComplete(TInt aError, 
        const TTimeIntervalMicroSeconds &aDuration)
    
    Description: From MMdaAudioPlayerCallback. Called when initialization is
                 complete.
    Comments   : 

    Return values:

-----------------------------------------------------------------------------
*/
void CCameraAppController::MapcInitComplete(TInt aError, 
    const TTimeIntervalMicroSeconds& /*aDuration*/)
    {
    if (!aError)
        {
        iSoundPlayer->SetVolume(iSoundPlayer->MaxVolume() / 3);
        iSoundPlayer->Play();
        }
    }

/*
-----------------------------------------------------------------------------

    void CCameraAppController::MapcPlayComplete(TInt aError)
    
    Description: From MMdaAudioPlayerCallback. Called when playback is
                 complete.
    Comments   : 

    Return values:

-----------------------------------------------------------------------------
*/
void CCameraAppController::MapcPlayComplete(TInt /*aError*/)
    {
    iSoundPlayer->Close();
    }


/*
-----------------------------------------------------------------------------

    void CCameraAppController::ClientRectChangedL(TRect& aRect)
    
    Description: Notify the controller if the client rect size changes
    Comments   : 

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CCameraAppController::ClientRectChangedL(const TRect& aRect)
    {
    if( !iCameraCaptureEngine )
        return;
        
    iCameraCaptureEngine->ClientRectChangedL(aRect);    
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -