You Are Here:

Community: Developer Discussion Boards

#1 Old How to remove flicker from drawing too fast on canvas? - 2008-07-07, 01:00

Join Date: Jun 2008
Posts: 12
Zamoth_bg
Offline
Registered User
Hello everyone!

I have done this school project for Visual User Interface class.
It is pretty cool but I do not like that the way I have done the animation everything is blinking and it does not look good.
I wonder if there is anyway to remove this flicker by using backbuffer or similar thing so it can be drawn before displaying.
If anyone can give me a hint that will be great.

I use blit() function of the canvas class.

Is there a better way?

I have uploaded everything you need to run it in emulator.

Put the "shoes.rar" in a directory /shoes of your python directory.
http://www.box.net/shared/zy7gb39c0c
and thses are the two modules:
http://www.box.net/shared/ssyldn9yck
http://www.box.net/shared/iphqu3sdcc


Here is a small snippet from the code:
Code:
def Draw(self,key,level,moveInDirection=None,frame=None):
		"""Drawing of the current item and its neigbour if possible."""
		global targetRecHandler
		if (level > 0):
			if(moveInDirection == None): #check if we are in the process of animation
				target = targetRecHandler.GetMeRectangle(zoomLvl=itemHandler.currentZoomLevel,key=key) #gets the rectangle needed
				if(target is not None): #check if we actually have an rectangle
					canvas.blit(self.picture, #takes current picture
					target=target,scale = 1)#draws current item
			else:
				if ((moveInDirection != "+") & (moveInDirection != "-")):
					animKey = key + str(itemHandler.currentZoomLevel-1) + "->" + key + moveInDirection + str(itemHandler.currentZoomLevel-1) #creates the animation key
					animKey = animKey.replace("ns","") #fixing some string problems with animation
					animKey = animKey.replace("sn","")
					animKey = animKey.replace("ew","")
					animKey = animKey.replace("we","")
				elif moveInDirection == "+":
					animKey = key + str(itemHandler.currentZoomLevel-1)  + "->" + key + str(itemHandler.currentZoomLevel-2)
				else:
					animKey = key + str(itemHandler.currentZoomLevel-1)  + "->" + key + str(itemHandler.currentZoomLevel)
				target = targetRecHandler.GetMeRectangle(key=animKey,frame=frame) #gets the rectangle needed
				if(target is not None): #check if we actually have an rectangle
					canvas.blit(self.picture,target=target,scale = 1)#draws current item
				
			self.__DrawNeighbours(key,level,moveInDirection,frame)
Reply With Quote

#2 Old Re: How to remove flicker from drawing too fast on canvas? - 2008-07-07, 07:49

Join Date: Dec 2007
Posts: 409
Location: Tempe, AZ
Send a message via Yahoo to shubhendra Send a message via Skype™ to shubhendra
shubhendra's Avatar
shubhendra
Offline
Forum Nokia Champion
Hi Zamoth_bg,
Did try your application, is really cool one.
Now about that blinking part is because image is being redrawn continuously.I think if you want the GUI types of maybe Apple's OS X then you need to use some graphics libraries.

The experts maybe will be able to elaborate more, i am really newbie in this GUI part.


IDEAS is all they need but still they think only Genius can give them that.
Reply With Quote

#3 Old Re: How to remove flicker from drawing too fast on canvas? - 2008-07-07, 10:03

Join Date: Jun 2008
Posts: 12
Zamoth_bg
Offline
Registered User
Thank you for the nice words. No I am saying if I can work on the same platform, same language if I can connect it to graphical API. Something to hack the code so it can dispaly stuff better.
Reply With Quote

#4 Old Re: How to remove flicker from drawing too fast on canvas? - 2008-07-07, 13:58

Join Date: Mar 2003
Posts: 937
Location: Espoo, Finland
JOM's Avatar
JOM
Offline
Forum Nokia Champion
Use double buffering, never ever draw directly on the canvas. In worst cases you can use also triple buffering.

Cheers,

--jouni sorry for being busy
Reply With Quote

#5 Old Re: How to remove flicker from drawing too fast on canvas? - 2008-07-07, 14:19

Join Date: Jun 2008
Posts: 12
Zamoth_bg
Offline
Registered User
I know but, how? Point me to what I need to use and a possible solution.
Reply With Quote

#6 Old Re: How to remove flicker from drawing too fast on canvas? - 2008-07-09, 17:49

Join Date: Mar 2003
Posts: 937
Location: Espoo, Finland
JOM's Avatar
JOM
Offline
Forum Nokia Champion
Quote:
Originally Posted by Zamoth_bg View Post
I know but, how? Point me to what I need to use and a possible solution.
Double Buffering is so easy, it's hard to think of example.. Possible surely and I should write a sample, but time is limited and it's more fun to do other things

Just updated Rol-a-Bol to version 1.4, wanted to experiment with triple buffering

http://jouni.miettunen.googlepages.com/rol-a-bol

Double Buffering:
  • Never draw on canvas
  • Create temporary empty image exactly similar to canvas
  • Draw everything on temp image, exactly like on canvas
  • Blit temp image on canvas
  • That's it

That's good enough for simple cases, no problems. In more demanding cases you have to optimize:
  • Create permanent "temp" image (off-screen)
  • Protect your draw routines (atomize)
  • Update screen as little as possible i.e. not full screen

Cheers,

--jouni
Reply With Quote

#7 Old Re: How to remove flicker from drawing too fast on canvas? - 2008-07-09, 18:36

Join Date: Jun 2008
Posts: 12
Zamoth_bg
Offline
Registered User
There is no real support of back buffer? I just create empty image and "draw" on it. Then just blip the image? Ok.
Reply With Quote

#8 Old Re: How to remove flicker from drawing too fast on canvas? - 2008-07-11, 07:41

Join Date: Mar 2003
Posts: 937
Location: Espoo, Finland
JOM's Avatar
JOM
Offline
Forum Nokia Champion
Quote:
Originally Posted by Zamoth_bg View Post
There is no real support of back buffer? I just create empty image and "draw" on it. Then just blip the image? Ok.
Yep,

It's just as easy as you said: create your own empty image, draw everything on it and blit on top of canvas.

Enjoy,

--jouni
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Canvas Drawing g_haddrell Mobile Java Media (Graphics & Sounds) 1 2008-02-04 14:22
Canvas keyPressed() not invoked when pressing too fast vichoty Mobile Java General 0 2005-12-18 09:42
Drawing on canvas close to edge is clipping james_levander Mobile Java Media (Graphics & Sounds) 1 2004-02-03 22:53
Major problem with delegation to Canvas bartekn Mobile Java Media (Graphics & Sounds) 8 2003-10-08 18:46
7650 and 3650 Canvas and FullCanvas memory marcilgen Mobile Java General 5 2003-07-08 13:24

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia