Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User g_costanza's Avatar
    Join Date
    Mar 2009
    Posts
    17
    Hi all,
    I'm working on a python script where I need to load something like 50-100 png images 30x50px big.
    I need to load them based on some conditions determined by user choice.

    I'm wondering what's the best practice to save resources:
    1. load the single pngs when needed
    2. load all of the pngs at the begining
    3. make a big png containing all the imgs and dividing them with "blit" as they do in here http://wiki.forum.nokia.com/index.ph..._using_sprites

    Thanks

    Giuseppe

  2. #2
    Registered User sogniator's Avatar
    Join Date
    Apr 2008
    Posts
    17
    1. load the single pngs when needed
    2. load all of the pngs at the begining
    3. make a big png containing all the imgs and dividing them with "blit" as they do in here http://wiki.forum.nokia.com/index.ph..._using_sprites
    Code:
    for img in img's path
        image.append(graphics.Image.open(img))
    Code:
    import graphics
    container = graphics.Image.new(desired_size)
    container.blit(png,coord)
    do u mean this

  3. #3
    Registered User g_costanza's Avatar
    Join Date
    Mar 2009
    Posts
    17
    Yes,
    Is this the most efficient method?

    thanks

    Giuseppe

  4. #4
    Registered User sogniator's Avatar
    Join Date
    Apr 2008
    Posts
    17
    Code:
    def png_loader(args):
       if type(args) == list:
           img.append([i for i in args])
           return img
       else:
           return graphics.Image.open(args)

  5. #5
    Regular Contributor aya42's Avatar
    Join Date
    Mar 2003
    Location
    UK
    Posts
    125
    Quote Originally Posted by g_costanza View Post
    3. make a big png containing all the imgs and dividing them with "blit"...
    This is probably quickest. If you want to save more time, you could 'blit' them on-demand.

  6. #6
    Super Contributor JOM's Avatar
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976
    Quote Originally Posted by g_costanza View Post
    I need to load something like 50-100 png images 30x50px big.
    I need to load them based on some conditions determined by user choice.

    I'm wondering what's the best practice to save resources:
    1. load the single pngs when needed
    2. load all of the pngs at the begining
    3. make a big png containing all the imgs and dividing them with "blit"
    Create one big file beforehands, load it at the beginning of your app and then do blit as needed. Opening and reading a file can be slow, you don't want to make your app look slow all the time. Slow startup is acceptable, especially if you have some wait dialog or splash screen at start.

    Cheers,

    --jouni

  7. #7
    Registered User g_costanza's Avatar
    Join Date
    Mar 2009
    Posts
    17
    Thanks jouni your answer sounds reasonable

    and thanks sogniator for the snippets.

    Giuseppe

Similar Threads

  1. How to display image from resources?
    By Juggle4Evr1 in forum Symbian User Interface
    Replies: 21
    Last Post: 2010-12-28, 17:28
  2. Nokia Image Converter
    By davidpurdie in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-18, 15:31
  3. Series 60 Emulator, reading image from resources ?
    By kakoskin in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2004-02-05, 11:19
  4. Replies: 7
    Last Post: 2003-06-27, 15:32
  5. Obfuscation.....loading image resources ?
    By HomerJ in forum Mobile Java General
    Replies: 1
    Last Post: 2002-12-03, 10:38

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved