summaryrefslogtreecommitdiff
path: root/imagecache.c
blob: 1ddc3e2438090e247099ee47ce891bef1a695e87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "imagecache.h"

cImageCache::cImageCache() {

}

cImageCache::~cImageCache() {
    
}

void cImageCache::Create(void) {
    for(int i = 0; i < MAX_IMAGE_CACHE; i++) {
        CacheImage[i] = NULL;
        CacheName[i] = "";
        CacheWidth[i] = -1;
        CacheHeight[i] = -1;
    }

    InsertIndex = 0;
}

void cImageCache::Clear(void) {
    for(int i = 0; i < MAX_IMAGE_CACHE; i++) {
        if( CacheImage[i] != NULL )
            delete CacheImage[i];
    }

    InsertIndex = 0;
}

cImage* cImageCache::GetImage(std::string Name, int Width, int Height) {
    for(int index = 0; index < MAX_IMAGE_CACHE; index++ ) {
        if( CacheName[index] == Name && CacheWidth[index] == Width && CacheHeight[index] == Height )
            return CacheImage[index];
    }
    return NULL;
}

void cImageCache::InsertImage(cImage *Image, std::string Name, int Width, int Height) {
    CacheImage[InsertIndex] = Image;
    CacheName[InsertIndex] = Name;
    CacheWidth[InsertIndex] = Width;
    CacheHeight[InsertIndex] = Height;

    InsertIndex++;
    if( InsertIndex >= MAX_IMAGE_CACHE ) {
        InsertIndex = 0;
    }
}