×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    17

    Image open resources saving best practice

    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
    Join Date
    Apr 2008
    Posts
    17

    Re: Image open resources saving best practice

    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
    Join Date
    Mar 2009
    Posts
    17

    Re: Image open resources saving best practice

    Yes,
    Is this the most efficient method?

    thanks

    Giuseppe

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    17

    Re: Image open resources saving best practice

    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
    Join Date
    Mar 2003
    Location
    UK
    Posts
    125

    Re: Image open resources saving best practice

    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
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Image open resources saving best practice

    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
    Join Date
    Mar 2009
    Posts
    17

    Re: Image open resources saving best practice

    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
  •  
×