rnd-20041124-1-src
[rocksndiamonds.git] / src / libgame / image.h
1 /***********************************************************
2 * Artsoft Retro-Game Library                               *
3 *----------------------------------------------------------*
4 * (c) 1994-2002 Artsoft Entertainment                      *
5 *               Holger Schemel                             *
6 *               Detmolder Strasse 189                      *
7 *               33604 Bielefeld                            *
8 *               Germany                                    *
9 *               e-mail: info@artsoft.org                   *
10 *----------------------------------------------------------*
11 * image.h                                                  *
12 ***********************************************************/
13
14 #ifndef IMAGE_H
15 #define IMAGE_H
16
17 #include "system.h"
18
19
20 #if defined(TARGET_X11)
21
22 #define MAX_COLORS      256     /* maximal number of colors for each image */
23
24 typedef unsigned short Intensity;       /* RGB intensity for X11 */
25
26 typedef struct
27 {
28   Display  *display;            /* destination display             */
29   int       depth;              /* depth of destination drawable   */
30   Pixel     index[MAX_COLORS];  /* array of pixel values           */
31   int       no;                 /* number of pixels in the array   */
32   Colormap  cmap;               /* colormap used for image         */
33   Pixmap   pixmap;              /* final pixmap                    */
34   Pixmap   pixmap_mask;         /* final pixmap of mask            */
35 } XImageInfo;
36
37 struct RGBMap
38 {
39   unsigned int used;                    /* number of colors used in RGB map */
40   Intensity    red[MAX_COLORS];         /* color values in X style          */
41   Intensity    green[MAX_COLORS];
42   Intensity    blue[MAX_COLORS];
43   boolean      color_used[MAX_COLORS];  /* flag if color cell is used       */
44 };
45
46 typedef struct
47 {
48   unsigned int  type;           /* type of image (True-Color etc.)     */
49   struct RGBMap rgb;            /* RGB map of image if IRGB type       */
50   unsigned int  width;          /* width of image in pixels            */
51   unsigned int  height;         /* height of image in pixels           */
52   unsigned int  depth;          /* depth of image in bits if IRGB type */
53   unsigned int  bytes_per_pixel;/* (depth + 7) / 8                     */
54   unsigned int  bytes_per_row;  /* width * bytes_per_pixel             */
55   byte         *data;           /* image data                          */
56 } Image;
57
58 #define IMAGETYPE_BITMAP        0       /* monochrome bitmap       */
59 #define IMAGETYPE_RGB           1       /* RGB image with colormap */
60 #define IMAGETYPE_TRUECOLOR     2       /* true-color image        */
61
62 #define TRUECOLOR_RED(pixel)    (((unsigned long)((pixel) & 0xff0000)) >> 16)
63 #define TRUECOLOR_GREEN(pixel)  (((unsigned long)((pixel) & 0xff00)) >> 8)
64 #define TRUECOLOR_BLUE(pixel)   ( (unsigned long)((pixel) & 0xff))
65 #define RGB_TO_TRUECOLOR(r,g,b) ((((unsigned long)((r) & 0xff00)) << 8) | ((g) & 0xff00) | (((unsigned short)(b)) >> 8))
66
67 Image *newImage(unsigned int, unsigned int, unsigned int);
68 void freeImage(Image *);
69 void freeXImage(Image *, XImageInfo *);
70
71 Pixmap Pixmap_to_Mask(Pixmap, int, int);
72
73 void ZoomPixmap(Display *, GC, Pixmap, Pixmap, int, int, int, int);
74
75 int Read_PCX_to_Pixmap(Display *, Window, GC, char *, Pixmap *, Pixmap *);
76
77 #endif /* TARGET_X11 */
78
79 int getImageListSize();
80 struct FileInfo *getImageListEntryFromImageID(int);
81 Bitmap *getBitmapFromImageID(int);
82 int getOriginalImageWidthFromImageID(int);
83 int getOriginalImageHeightFromImageID(int);
84 char *getTokenFromImageID(int);
85 int getImageIDFromToken(char *);
86 char *getImageConfigFilename();
87 int getImageListPropertyMappingSize();
88 struct PropertyMapping *getImageListPropertyMapping();
89 void InitImageList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
90                    char **, char **, char **, char **, char **);
91
92 void ReloadCustomImages();
93 void CreateImageWithSmallImages(int, int);
94
95 void FreeAllImages();
96
97 #endif  /* IMAGE_H */