You Are Here:

Community: Developer Discussion Boards

#1 Old Blitting image onto canvas results in white screens - 2009-06-28, 02:26

Join Date: Jun 2009
Posts: 10
monoceres
Offline
Registered User
Hi!

I just started developing apps to my nokia 5800 using python.

So I thought I made some simple graphics work with a background image but the result is unexpected (at least for me).

My code looks like this:
Code:
import appuifw
import e32
import graphics


appuifw.app.screen='full'


def quit():
    global running
    running=0
running=1
    
appuifw.app.exit_key_handler=quit

appuifw.app.title = u"test"

i = graphics.Image.open(u"e:\\background.jpg")
c = appuifw.Canvas()
appuifw.app.body=c


while running:
	c.blit(i)
	e32.ao_sleep(0.5)
It seems that the longer I sleep the main loop the longer sequences of blank white screens I get. When for example sleeping for 5 seconds I get ~5 seconds of white color while when using 5 ms I only get flashing white color. Removing the sleep solves the issue but makes it impossible to shutdown the app and I can't see how it's good programming. My conclusion is that the screen gets cleared somehow while the main thread is sleeping, why is this?

Running on the emulator btw.

Thanks in advance!
Reply With Quote

#2 Old Re: Blitting image onto canvas results in white screens - 2009-06-28, 03:34

Join Date: Mar 2003
Posts: 937
Location: Espoo, Finland
JOM's Avatar
JOM
Online
Forum Nokia Champion
You draw directly on canvas, ignoring system screen redraw callback. The white screen is caused by system redraw. Try something around this code:

Code:
def cb_redraw(dummy=(0, 0, 0, 0)):
    ''' Overwrite default screen redraw event handler '''
    if img:
        canvas.blit(img)

def draw():
    ''' Custom screen update routine '''
   img.clear(RGB_RED)
   img.ellipse(width=5, outline=RGB_BLACK)
   cb_redraw()

canvas = appuifw.Canvas(redraw_callback = cb_redraw)
appuifw.app.body = canvas
...please note that this code does not work, it's there just to give you the idea about how to do it...

Cheers,

--jouni
Reply With Quote

#3 Old Re: Blitting image onto canvas results in white screens - 2009-06-28, 16:05

Join Date: Jun 2009
Posts: 10
monoceres
Offline
Registered User
Thanks! I knew it was something simple
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
Load an image to the Canvas by using NetBeans 6.5 ochin Mobile Java Media (Graphics & Sounds) 10 2009-06-19 12:48
Canvas: How to draw a Rect around an image? ricardopcunha Mobile Java General 2 2009-02-10 18:34
switch between image canvas and console output ? sptkrishnan Python 2 2008-11-18 15:25
image should move randomly when collsion takes place without sprites using canvas paulmgeo Mobile Java Games 2 2008-06-19 08:02
Image loading on canvas pieterb23 Mobile Java General 2 2007-06-29 17:35

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 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d81449X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ