LoadImage() confusion ...

BlitzPlus Forums/BlitzPlus Programming/LoadImage() confusion ...

DNielsen(Posted 2004) [#1]
This is from the BlitzPlus Docs:

LoadImage()
Loads an image and returns its handle.

The optional flags parameter can be one of:

1 : managed (image is frequently drawn but seldom modified - this is the default)
2 : dynamic (image is frequently drawn and modified)
4 : scratch (image is seldom drawn or modified)

Managed images are the default.

Dynamic images are the fastest, but can be 'lost' when the display mode changes. This means the
contents of the image will be scrambled, and you will need to restore the image content. If you
are frequently redrawing the image contents, this isn't really a problem. If not, you should use
managed images!

Scratch images are slow all round but consume no videomemory. These are good for things like title
pages and 'temporary work' images.

Note that canvas buffers and back buffers should be considered 'dynamic'.

***************
It says there are 3 options (1 & 2 & 4) - what happened to option 3?? And where can I find a more in-depth technical explanation of the 3 options, and when its best to use either of them???


soja(Posted 2004) [#2]
1, 2, and 4 are the three options. It's not 1, 2, and 3 because it's easier to represent in binary for the computer.
1: 0001
2: 0010
4: 0100
So basically, the least-significant (rightmost) bit represents "managed", the next (to the left) is "dynamic", and the third is "scratch".
If it used 3, you'd end up with:
3: 0011
...which would mean both managed AND dynamic, which doesn't make sense, since they're mutually exclusive.

You'll find functions that take parameters like this all the time, for example, CreateWindow.

As for an in-depth technical explanation, I don't know... I do know that factors to consider are whether the image is stored in video RAM or system RAM. That would make certain operation faster or slower because of bus latency, etc.

My suggestion would be to ask yourself what category your image falls under according to the docs, then use the appropriate flag. Most often, the default is the right one to use.


DNielsen(Posted 2004) [#3]
@Soja,
Thanks a lot for the advice and help. I would still like to know the precise technical differences when using either of the 3 modes. Perhaps someone knows of an article somewhere?