One of the main problems when it comes to working with large images is memory there's never enough. To help you deal with this problem more effectively, ImageMan provides some tools which allow you to minimize your memory usage to some extent.
You've already seen how judicious use of the ImgCopy function can help you produce low-resolution copies of large images without ever loading the entire image into memory. The ImgUnload function takes this concept one step further by allowing you to discard unwanted bitmaps at run time, while still "keeping a handle on them" in the form of an ImageMan image handle. To understand how the ImgUnload function works, you need a little background on how ImageMan works, and why.
When an image is first opened by ImageMan, there's very little processing that takes place. Essentially, all that ImageMan does is to verify that the image is a valid image and return the image's parameters, including width, height, and color makeup. The actual image is not loaded at this time, for the very simple reason that it may not be needed at this time. In fact, a screen-displayable representation of this image may never be required by the application. This makes some things very easy, like making a smaller copy of a large image, because the original image is never loaded entirely. On the other hand, there's always this hanging question of when, exactly, is an image loaded? We basically take the approach that we'll load it whenever it's needed; that is, when some function is called which just has to have an image loaded to work properly, that's when we'll load the image.
This idea of delayed-loading, while flexible, can present some problems. For instance, if you call ImgDrawImage with a good-sized image, the supposedly fast operation of just drawing the image can take a second or so the first time, because the image has to be loaded before it can be drawn. To give the application some control over this situation, we've implemented the ImgLoad function, which enables your application to load all or part of an image on demand. This takes the guesswork out of when the image will be loaded, and lets you determine which portion of the image will be loaded.
The ImgUnload function allows you to unload one or all of a given image's in-memory representations, so that you never have more memory used than you actually need.
You can see how much flexibility we try to give to application developers with this setup; how you decide to use it is, of course, up to you, and we encourage you to experiment to determine what steps, if any, your application will take to minimize it's memory requirements.
© 1995-2004 Data Techniques, Inc. All rights reserved.