×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    10

    Blitting image onto canvas results in white screens

    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!

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Blitting image onto canvas results in white screens

    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

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    10

    Re: Blitting image onto canvas results in white screens

    Thanks! I knew it was something simple

Similar Threads

  1. Load an image to the Canvas by using NetBeans 6.5
    By ochin in forum Mobile Java Media (Graphics & Sounds)
    Replies: 10
    Last Post: 2009-06-19, 11:48
  2. Canvas: How to draw a Rect around an image?
    By ricardopcunha in forum Mobile Java General
    Replies: 2
    Last Post: 2009-02-10, 17:34
  3. switch between image canvas and console output ?
    By sptkrishnan in forum Symbian
    Replies: 2
    Last Post: 2008-11-18, 14:25
  4. Replies: 2
    Last Post: 2008-06-19, 07:02
  5. Image loading on canvas
    By pieterb23 in forum Mobile Java General
    Replies: 2
    Last Post: 2007-06-29, 16:35

Posting Permissions

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