src/extras/simplecamera.py
changeset 0 ca70ae20a155
equal deleted inserted replaced
-1:000000000000 0:ca70ae20a155
       
     1 # Copyright (c) 2008 Nokia Corporation
       
     2 #
       
     3 # Licensed under the Apache License, Version 2.0 (the "License");
       
     4 # you may not use this file except in compliance with the License.
       
     5 # You may obtain a copy of the License at
       
     6 #
       
     7 #     http://www.apache.org/licenses/LICENSE-2.0
       
     8 #
       
     9 # Unless required by applicable law or agreed to in writing, software
       
    10 # distributed under the License is distributed on an "AS IS" BASIS,
       
    11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    12 # See the License for the specific language governing permissions and
       
    13 # limitations under the License.
       
    14 
       
    15 import e32
       
    16 import appuifw
       
    17 import camera
       
    18 import key_codes
       
    19 
       
    20 def viewfinder_cb(img):
       
    21     appuifw.app.body.blit(img)
       
    22 
       
    23 def capture_cb():
       
    24     global photo
       
    25     photo=camera.take_photo()
       
    26     camera.stop_finder()
       
    27     lock.signal()
       
    28 
       
    29 old_body=appuifw.app.body
       
    30 appuifw.app.body=appuifw.Canvas()
       
    31 lock=e32.Ao_lock()
       
    32 photo=None
       
    33 camera.start_finder(viewfinder_cb)
       
    34 appuifw.app.body.bind(key_codes.EKeySelect, capture_cb)
       
    35 lock.wait()
       
    36 appuifw.app.body=old_body
       
    37 
       
    38 filename=u'c:\\photo.jpg'
       
    39 photo.save(filename)
       
    40 print "Photo taken and saved at:",filename