1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
19 #define MAX_COLORS 256 /* maximal number of colors for each image */
21 typedef unsigned short Intensity; /* what X thinks an RGB intensity is */
25 Display *display; /* destination display */
26 int screen; /* destination screen */
27 int depth; /* depth of drawable we want/have */
28 Drawable drawable; /* drawable to send image to */
29 Pixel *index; /* array of pixel values allocated */
30 int no; /* number of pixels in the array */
31 int rootimage; /* True if is a root image - eg, retain colors */
32 Pixel foreground; /* foreground and background pixels for mono images */
34 Colormap cmap; /* colormap used for image */
35 GC gc; /* cached gc for sending image */
36 GC gc_mask; /* cached gc for sending image mask */
37 XImage *ximage; /* ximage structure */
38 XImage *ximage_mask;/* ximage structure of mask */
39 Pixmap pixmap; /* final pixmap */
40 Pixmap pixmap_mask; /* final pixmap of mask */
45 unsigned int used; /* number of colors used in RGB map */
46 Intensity red[MAX_COLORS]; /* color values in X style */
47 Intensity green[MAX_COLORS];
48 Intensity blue[MAX_COLORS];
49 boolean color_used[MAX_COLORS]; /* flag if color cell is used */
54 struct RGBMap rgb; /* RGB map of image if IRGB type */
55 unsigned int width; /* width of image in pixels */
56 unsigned int height; /* height of image in pixels */
57 unsigned int depth; /* depth of image in bits if IRGB type */
58 byte *data; /* image data */
59 byte *data_mask; /* clip mask data */
63 * architecture independent memory-to-value conversions
64 * note: the internal format is big endian
67 #define memToVal(PTR,LEN) ( \
68 (LEN) == 1 ? (unsigned long)( *( (byte *)(PTR)) ) : \
69 (LEN) == 2 ? (unsigned long)(((unsigned long)(*( (byte *)(PTR)) ))<< 8) \
70 + ( *(((byte *)(PTR))+1) ) : \
71 (LEN) == 3 ? (unsigned long)(((unsigned long)(*( (byte *)(PTR)) ))<<16) \
72 + (((unsigned long)(*(((byte *)(PTR))+1)))<< 8) \
73 + ( *(((byte *)(PTR))+2) ) : \
74 (unsigned long)(((unsigned long)(*( (byte *)(PTR)) ))<<24) \
75 + (((unsigned long)(*(((byte *)(PTR))+1)))<<16) \
76 + (((unsigned long)(*(((byte *)(PTR))+2)))<< 8) \
77 + ( *(((byte *)(PTR))+3) ) )
79 #define valToMem(VAL,PTR,LEN) ( \
80 (LEN) == 1 ? (*( (byte *)(PTR) ) = ( VAL ) ) : \
81 (LEN) == 2 ? (*( (byte *)(PTR) ) = (((unsigned long)(VAL))>> 8), \
82 *(((byte *)(PTR))+1) = ( VAL ) ) : \
83 (LEN) == 3 ? (*( (byte *)(PTR) ) = (((unsigned long)(VAL))>>16), \
84 *(((byte *)(PTR))+1) = (((unsigned long)(VAL))>> 8), \
85 *(((byte *)(PTR))+2) = ( VAL ) ) : \
86 (*( (byte *)(PTR) ) = (((unsigned long)(VAL))>>24), \
87 *(((byte *)(PTR))+1) = (((unsigned long)(VAL))>>16), \
88 *(((byte *)(PTR))+2) = (((unsigned long)(VAL))>> 8), \
89 *(((byte *)(PTR))+3) = ( VAL ) ))
92 #define PCX_OpenFailed -1
93 #define PCX_ReadFailed -2
94 #define PCX_FileInvalid -3
95 #define PCX_NoMemory -4
96 #define PCX_ColorFailed -5
98 int Read_PCX_to_Pixmaps(Display *, Window, char *, Pixmap *, Pixmap *);
100 Image *Read_PCX_to_Image();