Results 1 to 15 of 15

Thread: Slow program access

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Singapore
    Posts
    98

    Slow program access

    Hi, i have a program which when i click certain tabs, a new picture will be loaded. However, thess pictures are relatively large and whenever i load it, it would take about 2 -3 seconds on my 750Mhz system to show/toggle. This toggling of pictures is very frequent in my destinated usage.

    Is there a way where i can load it and keep it in memory and thus no need to reload the picture which take a long time? Or is there a better alternative?

    Pls advice, thanks in advance.

  2. #2
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    I think if you put the pictures in a resource file, the'll stay in memory once you load them the first time

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Singapore
    Posts
    98
    Originally posted by phinds
    I think if you put the pictures in a resource file, the'll stay in memory once you load them the first time
    Sorry, but what do you mean by a resource file?
    Can you elaborate?

  4. #4
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    A high level idea.
    If you know in advance all the images that are going to be used
    you could load them all when the program starts and use a
    splash screen to cover the delay.
    I don't know if the computers resources could handle it though.

  5. #5
    Addicted Member Vegeta's Avatar
    Join Date
    Jul 2002
    Posts
    159
    What about loading all pictures u use into Pictureboxes (not visible), and if u need the pics, blit them to the Picturebox that is visible for the user.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Singapore
    Posts
    98
    Originally posted by Vegeta
    What about loading all pictures u use into Pictureboxes (not visible), and if u need the pics, blit them to the Picturebox that is visible for the user.
    Well, that would mean getting lots of picture boxes.

    deadeyes, your idea is similar to Vegeta's, unless there's a better place to load it into.

  7. #7
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    I think the idea of a resource file sounds good.

    How large (in bytes) are the pictures?

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Singapore
    Posts
    98
    Originally posted by Megatron
    I think the idea of a resource file sounds good.

    How large (in bytes) are the pictures?
    typically from 200k to 700k.
    Can someone explain resource file?

  9. #9
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    Resource files are part of the project: Just like Forms, Modules, and Class Modules. Resource files typically contain the program's resources. Resources can be pictures, sounds, strings, and other binary data.

    The first step to creating a resource file is to write up a resource script (*.rc file). Then use the resource compiler to compile it into a resource file (*.res).

    The resource compiler is located in the Tools\Rc directory of vb. There also a text file that explains how to use it.

  10. #10
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    Or, if you have VB6, there's a tool named Resource Editor that creates .res files for your program.

    Oh, and I want to add a question, can you replace VB's program icon by add an icon resource with an ID of one?


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Singapore
    Posts
    98
    Originally posted by Microbasic
    Or, if you have VB6, there's a tool named Resource Editor that creates .res files for your program.

    Oh, and I want to add a question, can you replace VB's program icon by add an icon resource with an ID of one?
    Hmmmm....dun see this resource editor in the add in manager or the directories mentioned.

  12. #12
    Lively Member
    Join Date
    Mar 2002
    Posts
    110
    why get so complicated?

    'put in declarations
    public pic1 as picture
    public pic2 as picture

    private sub form_load()

    pic1 = loadpicture ("path to picture here")
    pic2 = loadpicture("path to picture here")

    end sub

    now you just reference an picture/image properties by the variable, like so

    image1.image = pic1
    or
    picture1.picture= pic2

    it will be instantaneous with no load time, the only load time will be at the beginning when the pics are loaded into variables.

    private sub unload

    set pic1 = nothing
    set pic2 = nothing

    end sub

  13. #13
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    How many images are we talking about? Wouldn't it be faster to load them as needed from disk use LoadPicture? The resource file thing would be good for distribution, but I do not think it will make your app faster...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Singapore
    Posts
    98
    1 picture or image box may have many images switching in it.

  15. #15
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    "1 picture or image box may have many images switching in it." does not invalidate golgo13sf's solution in the least. Just switch the picture variables.

Posting Permissions

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



Click Here to Expand Forum to Full Width