added checking for invalid/malicious filenames in network protocol
[rocksndiamonds.git] / src / libgame / image.h
1 // ============================================================================
2 // Artsoft Retro-Game Library
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // image.h
10 // ============================================================================
11
12 #ifndef IMAGE_H
13 #define IMAGE_H
14
15 #include "system.h"
16
17
18 // these bitmap pointers either point to allocated bitmaps or are NULL
19 #define IMG_BITMAP_32x32        0
20 #define IMG_BITMAP_16x16        1
21 #define IMG_BITMAP_8x8          2
22 #define IMG_BITMAP_4x4          3
23 #define IMG_BITMAP_2x2          4
24 #define IMG_BITMAP_1x1          5
25 #define IMG_BITMAP_CUSTOM       6
26
27 #define NUM_IMG_BITMAPS         7
28
29 // this bitmap pointer points to one of the above bitmaps (do not free it)
30 #define IMG_BITMAP_GAME         7
31
32 #define NUM_IMG_BITMAP_POINTERS 8
33
34 // this bitmap pointer points to the bitmap with default image size
35 #define IMG_BITMAP_STANDARD     IMG_BITMAP_32x32
36
37
38 #define GET_BITMAP_ID_FROM_TILESIZE(x)  ((x) ==  1 ? IMG_BITMAP_1x1   : \
39                                          (x) ==  2 ? IMG_BITMAP_2x2   : \
40                                          (x) ==  4 ? IMG_BITMAP_4x4   : \
41                                          (x) ==  8 ? IMG_BITMAP_8x8   : \
42                                          (x) == 16 ? IMG_BITMAP_16x16 : \
43                                          (x) == 32 ? IMG_BITMAP_32x32 : \
44                                          IMG_BITMAP_CUSTOM)
45
46 #define GET_TILESIZE_FROM_BITMAP_ID(x)  ((x) == IMG_BITMAP_1x1   ? 1  : \
47                                          (x) == IMG_BITMAP_2x2   ? 2  : \
48                                          (x) == IMG_BITMAP_4x4   ? 4  : \
49                                          (x) == IMG_BITMAP_8x8   ? 8  : \
50                                          (x) == IMG_BITMAP_16x16 ? 16 : \
51                                          (x) == IMG_BITMAP_32x32 ? 32 : \
52                                          0)
53
54
55 int getImageListSize();
56 struct FileInfo *getImageListEntryFromImageID(int);
57 Bitmap **getBitmapsFromImageID(int);
58 int getOriginalImageWidthFromImageID(int);
59 int getOriginalImageHeightFromImageID(int);
60 char *getTokenFromImageID(int);
61 char *getFilenameFromImageID(int);
62 int getImageIDFromToken(char *);
63 char *getImageConfigFilename();
64 int getImageListPropertyMappingSize();
65 struct PropertyMapping *getImageListPropertyMapping();
66 void InitImageList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
67                    char **, char **, char **, char **, char **);
68
69 void ReloadCustomImages();
70 void CreateImageWithSmallImages(int, int, int);
71 void CreateImageTextures(int);
72 void FreeAllImageTextures();
73 void ScaleImage(int, int);
74
75 void FreeAllImages();
76
77 #endif  /* IMAGE_H */