Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # picture_resize.py
- from appuifw import *
- from graphics import *
- import e32,appuifw,os,sys,key_codes,time,math,graphics,sensor,string # No anti-alias or nearest?
- def draw(rect):
- try: canvas.blit(img)
- except: pass
- def quit():
- script_lock.signal()
- canvas = appuifw.Canvas(redraw_callback=draw)
- appuifw.app.directional_pad=False
- appuifw.app.orientation='portrait'
- appuifw.app.screen='large'
- appuifw.app.body=canvas
- w,h = canvas.size
- img=graphics.Image.new((w,h))
- sample = Image.open(unicode('e:\\python\\320x320.jpg')) # of a 3D Python Logo
- def actual():
- img.clear((0,0,0))
- img.blit(sample)
- draw(())
- def stretch():
- img.clear((0,0,0))
- img.blit(sample,scale=2)
- draw(())
- def shrink():
- img.clear((0,0,0))
- img.blit(sample.resize((120, 120)),target=(200,200))
- draw(())
- appuifw.app.menu = [(u'Actual Size', actual), (u'Stretch To Fit', stretch), (u'Shrink To 120x120', shrink) ]
- img.clear((0,0,0))
- img.blit(sample)
- draw(())
- lock = e32.Ao_lock()
- appuifw.app.exit_key_handler = lambda:lock.signal()
- lock.wait()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement