Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Korakot Chaovavanich http://korakot.stumbleupon.com

« Newer Snippets
Older Snippets »
Showing 11-12 of 12 total

Using Icon as Image

Pys60 1.1.3 have 2 differnt classes for graphics data.
Icon class represents icon (typically from .mbm file)
which can be put in ListBox for selection.
Image class represents a bigger image which can be
drawn upon. These 2 classes can't convert to/from
each other.

So, I create a library that read .mbm file and draw
an Image from the data there. So, you can make
an icon into an image (now only 1-bit icons).
the module can be downloaded from here
http://larndham.net/service/pys60/icon_image.py
from appuifw import *
import icon_image, e32

app.body = c = Canvas()
# choose a bitmap from plenty inside mbm (multi-bitmap)
icon = icon_image('z:\\system\\data\\avkon.mbm', 28) 
c.blit(icon)

e32.ao_sleep(10)  # 10 sec to end program

Look here for more information.
http://discussion.forum.nokia.com/forum/showthread.php?s=&threadid=63608

New camera module

A few days ago, I posted an example of how to take
a photo with py_s60 1.1.0. But now, a new and better
version (1.1.3) is released. The camera module has
improved significantly.

Now it can
- use different sizes (640x480 and 160x120 in my case)
- use zoom (0 or 1 in my case)
- take photos at 12, 16 or 24-bit color ('RGB12', 'RGB16', 'RGB')
- using flash ('none', 'auto', 'forced', 'fill_in', 'red_eye_reduce')
- set white-balance and exposure (I use 'auto' for both,
but sometimes I may use 'night' exposure)
- return an image object which can save in 'jpg' or 'png' format

You can see that these have good default values
 # copy from camera.py
def take_photo(
  mode='RGB16',
  size=(640, 480),
  zoom=0,
  flash='none',
  exposure='auto',
  white_balance='auto'):

So the simplest example is
import camera
im = camera.take_photo()  # use all default values
im.save(u'C:\\test.jpg')

You can see what you can set on your phone
from camera import *
print image_modes()
print image_sizes()
print max_zoom()
print flash_modes()
print exposure_modes()
print white_balance_modes()

« Newer Snippets
Older Snippets »
Showing 11-12 of 12 total