DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Can I put graphics in RAM?

  1. #1
    Join Date
    Apr 2004
    Location
    Hawaii
    Posts
    220

    Question Can I put graphics in RAM?

    Hi, I wonder if anyone can tell me if there's a way in VB6 to put the .gif files I use to fill image and picture controls into RAM so the hard drive does not have to be accessed each time I need to change a control's graphic (for example dealing cards).

    I've read up on the resource file, but this doesn't seem to fit my needs. First off, I'm not sure if the graphics stored there are actually kept in RAM (maybe someone could enlighten me), and second it can not handle .gifs, which I need for their transparency capability.

    Any input is appreciated.

    Thanks.

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    add a listImages control to your form, and at design time load there all the images you want. That will make the size of the exe a little bigger.... but then you do not have to distribute image files with your app. Or you can distribute the images file, and load them into the ListImages control (or in an array of StdPicture) at form load.
    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  3. #3
    Join Date
    Apr 2004
    Location
    Hawaii
    Posts
    220
    Marco, if I use your first suggestion (put all my images in a listImages control), they will be saved as part of the .exe, making it larger. Does this also mean they will remain in RAM once the exe is running (for easy access)? Or will VB auto find a way to use the hard drive for storage until they are actually displayed?

    As to your second suggestion what is meant by:

    "(or in an array of StdPicture)"

    Do you mean standard picture box controls? I could load the images into an array of picture box controls at run time, then draw from them as needed? If this is the case, are my images actually held in RAM once they are loaded into picture controls, whether they are being currently displayed or not?

    Thanks very much for your help!!!

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    the images stored in the exe are in the RAM (unless there is not enough space and the app swaps)
    I meant an array of image objects:

    Dim stdi(4) As StdPicture
    Set stdi(0) = LoadPicture(filename1)
    Set stdi(1) = LoadPicture(filename2)
    ......

    the advantage is that a StdPicture is not a visual controls, thus uses much less resources and space (unless the PictureBox control). When you need to display them, just load them into an Image control:

    Image1.Picture = stdi(0)

    and yes, an array of StdPicture objects is in RAM (same as above: unless there is not enough memory)

    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  5. #5
    Join Date
    Apr 2004
    Location
    Hawaii
    Posts
    220
    Marco! I have a new favorite control--the ImageList!!! I have little experience in the way of graphics and remember reading about the ImageList many moons ago, but always assumed it was used in animation (for some reason). I now know I was wrong--and have several projects that need some re-writing in their minor use of graphics.

    Then after seeing your post above and still being confused about this StdPicture construct I ran a search in VB using "StdPicture" and found out it is also it's own control. I didn't realize that before and don't ever remember reading about it (obviously not a VB expert). Not only do I now undertsand the examples you were trying to use, but I realize the next week or so is going to be spent going back and studying any graphics related VB controls. It's like a new world!

    Thanks very much for pointing me the right way!

  6. #6
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    actually the StdPicture is not a control, but a data type (in this case an Object). it can be used to store pictures in memory without the need of any visual controls.

    The following is a disclaimer. VB is not the right language to do enhanced graphics, all the graphics I do in VB uses WIndows API. And remember that VB is going to die of a slow and painful death :-( If you want to learn more for the future I suggest you to go with VB.NET, that uses the powerful gdi+ library via the system.drawing namespace

    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center