<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: zoom code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 01:18:04 GMT</pubDate>
    <description>DZone Snippets: zoom code</description>
    <item>
      <title>Using the mousewheel to zoom in or out an SVG document</title>
      <link>http://snippets.dzone.com/posts/show/5337</link>
      <description>This code was originally copied from &lt;a href="http://adomas.org/javascript-mouse-wheel/"&gt;Mouse wheel programming in JavaScript&lt;/a&gt; [adomas.org]. I replaced about 5 lines of code to get the mousewheel controlling the zoom feature in the &lt;a href="http://snippets.dzone.com/posts/show/5336"&gt;makeZoom.svg&lt;/a&gt; [dzone.com] file.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  /** This is high-level function; REPLACE IT WITH YOUR CODE.&lt;br /&gt; * It must react to delta being more/less than zero.&lt;br /&gt; */&lt;br /&gt;function zoomInOut(delta) {&lt;br /&gt;	if (delta &gt;= 0)&lt;br /&gt;		zoomIn()&lt;br /&gt;	else&lt;br /&gt;		zoomOut()&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function wheel(event){&lt;br /&gt;	var delta = 0;&lt;br /&gt;	if (!event) event = window.event;&lt;br /&gt;	if (event.wheelDelta) {&lt;br /&gt;		delta = event.wheelDelta/120; &lt;br /&gt;		if (window.opera) delta = -delta;&lt;br /&gt;	} else if (event.detail) {&lt;br /&gt;		delta = -event.detail/3;&lt;br /&gt;	}&lt;br /&gt;	if (delta)&lt;br /&gt;		zoomInOut(delta);&lt;br /&gt;        if (event.preventDefault)&lt;br /&gt;                event.preventDefault();&lt;br /&gt;        event.returnValue = false;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* Initialization code. */&lt;br /&gt;if (window.addEventListener)&lt;br /&gt;	window.addEventListener('DOMMouseScroll', wheel, false);&lt;br /&gt;window.onmousewheel = document.onmousewheel = wheel;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 08 Apr 2008 16:14:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5337</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Java - ZoomOUT image</title>
      <link>http://snippets.dzone.com/posts/show/2924</link>
      <description>&lt;code&gt;&lt;br /&gt;public BufferedImage zoomOut(BufferedImage bi, int scale)&lt;br /&gt;	{&lt;br /&gt;		int width = bi.getWidth() / scale;&lt;br /&gt;		int height = bi.getHeight() / scale;&lt;br /&gt;		&lt;br /&gt;		BufferedImage biScale = new BufferedImage(width, height, bi.getType());&lt;br /&gt;		&lt;br /&gt;		for(int i=0; i&lt;width; i++)&lt;br /&gt;			for(int j=0; j&lt;height; j++)&lt;br /&gt;				biScale.setRGB(i, j, bi.getRGB(i*scale, j*scale));&lt;br /&gt;		&lt;br /&gt;		return biScale;&lt;br /&gt;	}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 30 Oct 2006 03:03:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2924</guid>
      <author>whitetiger ()</author>
    </item>
    <item>
      <title>Java - ZoomIN Image</title>
      <link>http://snippets.dzone.com/posts/show/2923</link>
      <description>&lt;code&gt;&lt;br /&gt;public BufferedImage zoomIn(BufferedImage bi, int scale)&lt;br /&gt;	{&lt;br /&gt;		int width = scale * bi.getWidth();&lt;br /&gt;		int height = scale * bi.getHeight();&lt;br /&gt;		&lt;br /&gt;		BufferedImage biScale = new BufferedImage(width, height, bi.getType());&lt;br /&gt;		&lt;br /&gt;                // Cicla dando un valore medio al pixel corrispondente&lt;br /&gt;		for(int i=0; i&lt;width; i++)&lt;br /&gt;			for(int j=0; j&lt;height; j++)&lt;br /&gt;				biScale.setRGB(i, j, bi.getRGB(i/scale, j/scale));&lt;br /&gt;		&lt;br /&gt;		return biScale;&lt;br /&gt;	}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 30 Oct 2006 02:49:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2923</guid>
      <author>whitetiger ()</author>
    </item>
    <item>
      <title>Using google map on mobile phone</title>
      <link>http://snippets.dzone.com/posts/show/458</link>
      <description>Download the tile images for testing&lt;br /&gt;&lt;code&gt;&lt;br /&gt;from urllib import urlretrieve&lt;br /&gt;turl =  'http://mt.google.com/mt?v=w2.4&amp;x=%s&amp;y=%s&amp;zoom=%s'&lt;br /&gt;tfile = '%s-%s-%s.gif'&lt;br /&gt;z = 12&lt;br /&gt;for x in range(5,10):&lt;br /&gt;  for y in range(10,14):&lt;br /&gt;    urlretrieve(turl % (x,y,z), tfile % (z,y,x))&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Then put the images in the phone. Then use the following code&lt;br /&gt;to browse around the images (and zoom in/out)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;from appuifw import *&lt;br /&gt;from key_codes import *&lt;br /&gt;from graphics import Image&lt;br /&gt;import e32&lt;br /&gt;&lt;br /&gt;app.screen = 'full'&lt;br /&gt;app.body = c= Canvas()&lt;br /&gt;&lt;br /&gt;x, y, z = 10*256, 24*256, 11&lt;br /&gt;dirname = u'C:\\system\\data\\gmap\\'  # where I save the tile images&lt;br /&gt;&lt;br /&gt;def draw():&lt;br /&gt;    gx, ox = divmod(x, 256)&lt;br /&gt;    gy, oy = divmod(y, 256)&lt;br /&gt;    f = dirname + '%s-%s-%s.gif' % (z,gy,gx)&lt;br /&gt;    c.blit(Image.open(f), target=(-ox,-oy))&lt;br /&gt;&lt;br /&gt;    if ox &gt; 80:&lt;br /&gt;        f = dirname + '%s-%s-%s.gif' % (z,gy,gx+1)&lt;br /&gt;        c.blit(Image.open(f), target=(256-ox,-oy))&lt;br /&gt;    if oy &gt; 48:&lt;br /&gt;        f = dirname + '%s-%s-%s.gif' % (z,gy+1,gx)&lt;br /&gt;        c.blit(Image.open(f), target=(-ox,256-oy))&lt;br /&gt;    if ox &gt; 80 and oy &gt; 48:&lt;br /&gt;        f = dirname + '%s-%s-%s.gif' % (z,gy+1,gx+1)&lt;br /&gt;        c.blit(Image.open(f), target=(256-ox,256-oy))&lt;br /&gt;&lt;br /&gt;def move(dx,dy):&lt;br /&gt;    global x, y&lt;br /&gt;    x += dx * 50&lt;br /&gt;    y += dy * 50&lt;br /&gt;    draw()&lt;br /&gt;&lt;br /&gt;def zoomin():&lt;br /&gt;    global x,y,z&lt;br /&gt;    x = x*2 + 88&lt;br /&gt;    y = y*2 + 104&lt;br /&gt;    z = z-1&lt;br /&gt;    draw()&lt;br /&gt;&lt;br /&gt;def zoomout():&lt;br /&gt;    global x,y,z&lt;br /&gt;    x = x/2 - 44&lt;br /&gt;    y = y/2 - 52&lt;br /&gt;    z = z+1&lt;br /&gt;    draw()&lt;br /&gt;&lt;br /&gt;c.bind(EKeyRightArrow,lambda:move(1, 0))&lt;br /&gt;c.bind(EKeyLeftArrow,lambda:move(-1, 0))&lt;br /&gt;c.bind(EKeyUpArrow,lambda:move(0, -1))&lt;br /&gt;c.bind(EKeyDownArrow,lambda:move(0, 1))&lt;br /&gt;c.bind(EKeySelect, zoomin)&lt;br /&gt;c.bind(EKeyStar, zoomout)&lt;br /&gt;&lt;br /&gt;running = 1&lt;br /&gt;def quit():&lt;br /&gt;    global running&lt;br /&gt;    running = 0&lt;br /&gt;app.exit_key_handler= quit&lt;br /&gt;&lt;br /&gt;draw()&lt;br /&gt;while running:&lt;br /&gt;    e32.ao_sleep(0.1)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;I put a bit more explanation in Nokia's forum here. (Newer version is available)&lt;br /&gt;http://discussion.forum.nokia.com/forum/showthread.php?s=&amp;postid=153609&lt;br /&gt;Also see the screenshot here&lt;br /&gt;http://flickr.com/photos/korakot/30189624/</description>
      <pubDate>Tue, 05 Jul 2005 03:55:36 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/458</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>New camera module</title>
      <link>http://snippets.dzone.com/posts/show/397</link>
      <description>A few days ago, I posted an example of how to take&lt;br /&gt;a photo with py_s60 1.1.0. But now, a new and better&lt;br /&gt;version (1.1.3) is released. The camera module has&lt;br /&gt;improved significantly.&lt;br /&gt;&lt;br /&gt;Now it can&lt;br /&gt;- use different sizes (640x480 and 160x120 in my case)&lt;br /&gt;- use zoom (0 or 1 in my case)&lt;br /&gt;- take photos at 12, 16 or 24-bit color ('RGB12', 'RGB16', 'RGB')&lt;br /&gt;- using flash ('none', 'auto', 'forced', 'fill_in', 'red_eye_reduce')&lt;br /&gt;- set white-balance and exposure (I use 'auto' for both,&lt;br /&gt;  but sometimes I may use 'night' exposure)&lt;br /&gt;- return an image object which can save in 'jpg' or 'png' format&lt;br /&gt;&lt;br /&gt;You can see that these have good default values&lt;br /&gt;&lt;code&gt; # copy from camera.py&lt;br /&gt;def take_photo(&lt;br /&gt;  mode='RGB16',&lt;br /&gt;  size=(640, 480),&lt;br /&gt;  zoom=0,&lt;br /&gt;  flash='none',&lt;br /&gt;  exposure='auto',&lt;br /&gt;  white_balance='auto'):&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;So the simplest example is&lt;br /&gt;&lt;code&gt;&lt;br /&gt;import camera&lt;br /&gt;im = camera.take_photo()  # use all default values&lt;br /&gt;im.save(u'C:\\test.jpg')&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;You can see what you can set on your phone&lt;br /&gt;&lt;code&gt;&lt;br /&gt;from camera import *&lt;br /&gt;print image_modes()&lt;br /&gt;print image_sizes()&lt;br /&gt;print max_zoom()&lt;br /&gt;print flash_modes()&lt;br /&gt;print exposure_modes()&lt;br /&gt;print white_balance_modes()&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 19 Jun 2005 21:56:26 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/397</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
