Friday 12 January 2007
Use of view finder
# Copyright (c) 2007 LEFEVRE Damien # Camera application # use the options key to select Start, Stop, Capture, Save and Exit functions import appuifw, e32, camera SCRIPT_LOCK = e32.Ao_lock( ) IMG = None def __exit__( ): stop( ) SCRIPT_LOCK.signal( ) def start( ): camera.start_finder( vfCallback ) appuifw.app.menu = [(u'Capture', capture), (u'Stop', stop), (u'Exit', __exit__)] def stop( ): camera.stop_finder( ) cnvCallback( ) appuifw.app.menu = [(u'Start', start), (u'Save', capture), (u'Exit', __exit__)] def vfCallback( aIm ): global IMG appuifw.app.body.blit( aIm ) IMG = aIm def cnvCallback( aRect=None ): if IMG != None: appuifw.app.body.clear( ) appuifw.app.body.blit( IMG ) def capture( ): camera.stop_finder( ) cnvCallback( ) appuifw.app.menu = [(u'Start', start), (u'Exit', __exit__)] if e32.in_emulator( ): IMG.save(u'C:\\Images\\viewfinder.png') else: IMG.save(u'E:\\Images\\viewfinder.png') appuifw.note(u'Saved', 'info') appuifw.app.exit_key_handler = __exit__ appuifw.app.title= u'PyS60 ViewFinder' appuifw.app.body = appuifw.Canvas( redraw_callback = cnvCallback) start( ) SCRIPT_LOCK.wait( )