Results 1 to 12 of 12

Thread: Bitmap loading

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Posts
    74

    Bitmap loading

    Ok I have a question about loading bitmaps into your game from disk. I'm designing an adventure game that loads a new bitmap background for each screen.

    Here's the code I'm useing ScreenArray is an array of strings that store the names of the bitmaps that make up background pictures.

    frmSprites.picBackground.Picture = LoadPicture(App.Path & "\Dat\Bak\" & ScreenArray(LocX, LocY) & ".bmp")

    There is a noticable delay loading new screens when you first start the game, however once you go to a certain screen it always loads faster if you need to go back to it again later even though it goes through the same reloading process again. Does anyone know how I can speed this process up right from the start of the game?
    All will fall before the might of the Black Sashi...

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    It's stored in memory once you load it, for the remainder of your program, until you delete it (how, I don't know, but I haven't looked into it). You won't be able to speed this up as there is no faster way to load from the disk. Maybe there is, but this might be lost with the overhead of programming it in VB. I suggest just letting your users know there's going to be a wait.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Posts
    74

    well

    Well I would like to know the exact dynamics of how it works, because unlike memory dc's you can perpetually load new bitmaps into a picture box as the program runs over and over again without running out of memory. So at some point I assume it replaces memory locations with new bitmaps, the fact that I can't fully understand how it does this is what bothers me.
    All will fall before the might of the Black Sashi...

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Well I'm pretty sure 90% of the time is seek time, and that Windows has an internal handler, keeping seek points in memory to oft-used files. Thus, it would be faster loading it the second time.

    But, I do fully agree with you. I hate not understanding how something works
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409
    one thing that may sped up the process is to have all your pictures in one file and have the top,left of where each is and then just load them to the pic boxs once and from then on always get them useing there location in that one picture to do this you will have to use bitblt or several set pixel calls if you dont already know this you can learn it or just do it another way.

    for this youll need another picbox to store the pics in.

    this may be faster but if you have alot of picture and they arent all used alto it may actually be slower im not shure

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Posts
    74

    Memory

    Well that would produce one long load time at the start as oppose to many short ones, that would be preferable except that it would cost a huge amount of memory to hold that many backgrounds at once. They are 600X480 and there are around 100 of them. thats 64000 pixels by 480 pixels. I'm trying to keep it down to 32 megs minimum system requirements I doubt 32 megs could hold that much graphical information at once.
    All will fall before the might of the Black Sashi...

  7. #7
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409
    yeah for your situation(when you have lots of pictures) thats probally not the best way to do it

  8. #8
    Member
    Join Date
    Nov 2002
    Location
    Barberton Ohio
    Posts
    42
    A Picturebox will support .jpg's and they are a fraction of the size. Just Convert your .bmp's to .jpg's. Maybe that'll help since it won't take up as much memory.

  9. #9
    Addicted Member
    Join Date
    Oct 2002
    Location
    Somewhere out in space
    Posts
    151
    Originally posted by Steven8
    A Picturebox will support .jpg's and they are a fraction of the size. Just Convert your .bmp's to .jpg's. Maybe that'll help since it won't take up as much memory.
    I don't think so, Sure it will take less space on the disk, but once the jpg will be loaded (decompressed) it will probably take as much space in memory as the bitmap used to create the jpg.

    As for the loading thing... could it be possible that using the LoadImage API and then blitting it to your picture box be faster? When you use vb's LoadPicture, vb as to convert your image into an iPictureDisp object and then setting it to the Picture object of the PictureBox ( wich i'm pretty sure is something that slows down the process of having your picture inside your picture box.)

    If i'm wrong... well i really don't know what you could do. I can only say that using tiles to create your backgrounds (unless they are to much different one from another) would have been a bether way and would have really reduce the size of the bitmaps you need to load.

    - Valkan
    'You keep creatures in cages and release them to fight? That's sick!'

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Posts
    74

    Smile Thanks

    Thanks for all the replies. What I've found to be the best method (although it may sound kind of dumb, is just to initalize the game by having all the backgrounds load into the picture box one after another. That way as Sastraxi said:

    "Windows has an internal handler, keeping seek points in memory to oft-used files. Thus, it would be faster loading it the second time."

    Without wasteing memory windows gets the idea that it might have to find that file again soon so the seek time drops down significantly, because it seeks through those files first. 100 bitmaps doesn't put a dent in the efficiantcy of this but I imagine a really huge amount like 10,000 would. But I dont' need that many so problem solved for now.
    All will fall before the might of the Black Sashi...

  11. #11
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Just to let you know, as you get farther along in your programming, you'll realise how useful Tile Engines really are. You'd never have this problem
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Posts
    74

    Tiles

    Yeah but my game is similar in nature to the old sierra or lucas arts adventure games. Every background is hand drawn and compleatly unique so I can't really get away with using tiles.
    All will fall before the might of the Black Sashi...

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