Code:
import e32, appuifw, camera, time, key_codes
appuifw.app.orientation='landscape'
appuifw.app.screen = 'normal'
full_path_str = 'C:\\Nokia\\Images\\%s.jpg'
global pic_name
location_i = 0 # 0 for phone memory, 1 for memory card
print_date_i = 1 # print the date on the picture
#------------- location_i -----------------
def save_on_c():
global full_path_str, location_i
full_path_str = 'C:\\Nokia\\Images\\%s.jpg'
location_i = 0
def save_on_e():
global full_path_str, location_i
full_path_str = 'E:\\Images\\%s.jpg'
location_i = 1
#--------------- white balance ----------
white_bal_str = 'auto'
def whbal_auto():
global white_bal_str
white_bal_str = 'auto'
def whbal_daylight():
global white_bal_str
white_bal_str = 'daylight'
def whbal_cloudy():
global white_bal_str
white_bal_str = 'cloudy'
def whbal_fluorescent():
global white_bal_str
white_bal_str = 'fluorescent'
def whbal_tungsten():
global white_bal_str
white_bal_str = 'tungsten'
#--------------- flash modes ------------
flash_mode = 'auto'
def flash_auto():
global flash_mode
flash_mode = 'auto'
def flash_on():
global flash_mode
flash_mode = 'forced'
def flash_off():
global flash_mode
flash_mode = 'none'
#------------- exposure -----------------
exp_mode = 'auto'
def exp_auto():
global exp_mode
exp_mode = 'auto'
def exp_center():
global exp_mode
exp_mode = 'center'
def exp_night():
global exp_mode
exp_mode = 'night'
#------------ picture size --------------
pic_size_tup = (1600, 1200)
def set_max():
global pic_size_tup
pic_size_tup = (1600, 1200)
def set_1024():
global pic_size_tup
pic_size_tup = (1024, 768)
def set_800():
global pic_size_tup
pic_size_tup = (800, 600)
def set_vga():
global pic_size_tup
pic_size_tup = (640, 480)
def set_min():
global pic_size_tup
pic_size_tup = (160, 120)
#--------- date printing ---------------
def date_printing_on():
global print_date_i
print_date_i = 1
def date_printing_off():
global print_date_i
print_date_i = 0
def viewfinder(img):
canvas.blit(img)
def shoot():
camera.stop_finder()
photo = camera.take_photo('RGB',pic_size_tup,0,flash_mode,exp_mode,white_bal_str,0)
canvas.blit(photo, target = (0, 0, w, h), scale = 1)
ltime=time.localtime()
if ltime[1] == 1:
month = '-Jan-'
elif ltime[1] == 2:
month = '-Feb-'
elif ltime[1] == 3:
month = '-Mar-'
elif ltime[1] == 4:
month = '-Apr-'
elif ltime[1] == 5:
month = '-May-'
elif ltime[1] == 6:
month = '-Jun-'
elif ltime[1] == 7:
month = '-Jul-'
elif ltime[1] == 8:
month = '-Aug-'
elif ltime[1] == 9:
month = '-Sep-'
elif ltime[1] == 10:
month = '-Oct-'
elif ltime[1] == 11:
month = '-Nov-'
elif ltime[1] == 12:
month = '-Dec-'
dd = ltime[2]
if dd < 10 :
dd = "0" + str(ltime[2])
hh = ltime[3]
if hh == 0 :
hh = 22
elif hh == 1 :
hh = 23
elif hh < 12 :
hh = "0" + str(ltime[3] - 2)
else : hh = ltime[3] - 2
min = ltime[4]
if min < 10 :
min = "0" + str(ltime[4])
sc = ltime[5]
if sc < 10 :
sc = "0" + str(ltime[5])
date = str(dd) + month + str(ltime[0]) + u' ' + str(hh) + u':' + str(min) + u':' + str(sc)
photo.text((20, 20), date, 0x00FF00, 'normal')
photo.save(full_path_str%date, format='JPEG', quality=100, bpp=24, compression='none')
camera.start_finder(viewfinder, size=(h * 1.34, h))
def exit():
camera.stop_finder()
app_lock.signal()
appuifw.app.body = canvas = appuifw.Canvas()
w, h = canvas.size
camera.start_finder(viewfinder, size=(h * 1.34, h))
menu = [(u'Image size',((u'1600x1200', set_max),
(u'1024x768', set_1024),
(u'800x600', set_800),
(u'640x480', set_vga),
(u'160x120', set_min)
)
),
(u"Flash mode",((u"Auto",flash_auto),
(u"On", flash_on),
(u"Off", flash_off)
)
),
(u"Exposure",((u"Auto", exp_auto),
(u"Center",exp_center),
(u"Night", exp_night)
)
),
(u'White balance',((u'Auto', whbal_auto),
(u'Daylight', whbal_daylight),
(u'Cloudy', whbal_cloudy),
(u'Neon', whbal_fluorescent),
(u'Tungsten', whbal_tungsten)
)
),
(u'Print date on image', ((u'On', date_printing_on),
(u'Off', date_printing_off)
)
),
(u'Memory in use', ((u'Phone memory', save_on_c),
(u'Memory card', save_on_e)
)
)
]
appuifw.app.menu = menu
canvas.bind(key_codes.EKeySelect, shoot)
canvas.bind(key_codes.EKeyRightSoftkey, exit)
app_lock = e32.Ao_lock()
app_lock.wait()