rnd-19981114-1
[rocksndiamonds.git] / src / image.h
1 /***********************************************************
2 *  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
3 *----------------------------------------------------------*
4 *  (c) 1995-98 Artsoft Entertainment                       *
5 *              Holger Schemel                              *
6 *              Oststrasse 11a                              *
7 *              33604 Bielefeld                             *
8 *              phone: ++49 +521 290471                     *
9 *              email: aeglos@valinor.owl.de                *
10 *----------------------------------------------------------*
11 *  image.h                                                 *
12 ***********************************************************/
13
14 #ifndef IMAGE_H
15 #define IMAGE_H
16
17 #include "main.h"
18
19 #define MAX_COLORS      256     /* maximal number of colors for each image */
20
21 typedef unsigned short Intensity;       /* RGB intensity for X11 */
22
23 typedef struct
24 {
25   Display  *display;            /* destination display             */
26   int       screen;             /* destination screen              */
27   int       depth;              /* depth of destination drawable   */
28   Pixel     index[MAX_COLORS];  /* array of pixel values           */
29   int       no;                 /* number of pixels in the array   */
30   Colormap  cmap;               /* colormap used for image         */
31   Pixmap   pixmap;              /* final pixmap                    */
32   Pixmap   pixmap_mask;         /* final pixmap of mask            */
33 } XImageInfo;
34
35 struct RGBMap
36 {
37   unsigned int used;                    /* number of colors used in RGB map */
38   Intensity    red[MAX_COLORS];         /* color values in X style          */
39   Intensity    green[MAX_COLORS];
40   Intensity    blue[MAX_COLORS];
41   boolean      color_used[MAX_COLORS];  /* flag if color cell is used       */
42 };
43
44 typedef struct
45 {
46   struct RGBMap rgb;            /* RGB map of image if IRGB type       */
47   unsigned int  width;          /* width of image in pixels            */
48   unsigned int  height;         /* height of image in pixels           */
49   unsigned int  depth;          /* depth of image in bits if IRGB type */
50   byte         *data;           /* image data                          */
51 } Image;
52
53 #define PCX_Success              0
54 #define PCX_OpenFailed          -1
55 #define PCX_ReadFailed          -2
56 #define PCX_FileInvalid         -3
57 #define PCX_NoMemory            -4
58 #define PCX_ColorFailed         -5
59
60 int Read_PCX_to_Pixmaps(Display *, Window, GC, char *, Pixmap *, Pixmap *);
61
62 Image *Read_PCX_to_Image(char *);
63 Image *newImage(unsigned int, unsigned int, unsigned int);
64 void freeImage(Image *);
65 void freeXImage(Image *, XImageInfo *);
66
67 #endif  /* IMAGE_H */