Nateo Tutorial: Bitmaps and Icons
The set of data items you store within the
- Not all objects are visible at a time. You need to have only those bitmaps in memory that are either visible or can be made visible by scrolling left to right in one sweep.
- Some data objects might share the same bitmap or icon. If certain events are marked by a certain icon and these events take place many times, it is enough to store the icon once and then use it to display all the events of this type. So in general it makes sense not to store the bitmap within the data object but rather store a key in the data object and then pick the bitmap from a dictionary. If several objects then hold the same key, they will be displayed by the same bitmap or icon.
This section describes how the
Bitmaps:
In general bitmaps differ in size and are bigger than icons. For this reason it makes sense to keep only those bitmaps in memory that are actually needed.
Icons:
An icon represents a certain value that might occur many times in a data set. And as icons are pretty small, it makes sense to load all of them on application startup and keep them throughout run
time. For example if you want to display temperature values by icons you might have only three icons (temperature too low, temperature ok, temperature too high) in order to show a series of many thousand
temperature values over time. In such a case it will not make sense to load icons dynamically when they are needed. You will load them at startup and keep them in memory.
How to set up efficient image handling along with the Time Chart?
Whenever the
Suppose, a data type 'Temperature' with
Now suppose another data type 'PDF-Documents' with
This implementation is not really professional but it shows the trick: When bitmaps are being used frequently, they are taken from the dictionary and no slow loading from file is needed. Still the dictionary is
protected agains getting too big. And most of all: In contrast to the icons (see above), bitmaps that are never used will never be loaded. The maximum memory consumption can be calculated quite well as long as you
know the size of the bitmaps.
Back to Overview
