1 /*
2  * This file is distributed with Ghostscript, but its author,
3  * Tanmoy Bhattacharya (tanmoy@qcd.lanl.gov) hereby places it in the
4  * public domain.
5  *
6  * The contents of this file were derived (indeed, largely copied) from
7  * the file image.h on SGI's file server; there is no copyright on that file.
8  */
9 
10 /*$Id: gdevsgi.h,v 1.1 2000/03/09 08:40:41 lpd Exp $*/
11 /* SGI raster file definitions */
12 
13 #ifndef gdevsgi_INCLUDED
14 #  define gdevsgi_INCLUDED
15 
16 #define IMAGIC 	0732
17 
18 /* colormap of images */
19 #define CM_NORMAL		0
20 #define CM_DITHERED		1
21 #define CM_SCREEN		2
22 #define CM_COLORMAP		3
23 #define TYPEMASK		0xff00
24 #define BPPMASK			0x00ff
25 #define ITYPE_VERBATIM		0x0000
26 #define ITYPE_RLE		0x0100
27 #define ISRLE(type)		(((type) & 0xff00) == ITYPE_RLE)
28 #define ISVERBATIM(type)	(((type) & 0xff00) == ITYPE_VERBATIM)
29 #define BPP(type)		((type) & BPPMASK)
30 #define RLE(bpp)		(ITYPE_RLE | (bpp))
31 #define VERBATIM(bpp)		(ITYPE_VERBATIM | (bpp))
32 #define	IBUFSIZE(pixels)	((pixels+(pixels>>6))<<2)
33 #define	RLE_NOP			0x00
34 
35 #define	ierror(p)		(((p)->flags&_IOERR)!=0)
36 #define	ifileno(p)		((p)->file)
37 #define	getpix(p)		(--(p)->cnt>=0 ? *(p)->ptr++ : ifilbuf(p))
38 #define putpix(p,x)		(--(p)->cnt>=0 \
39 				    ? ((int)(*(p)->ptr++=(unsigned)(x))) \
40 				    : iflsbuf(p,(unsigned)(x)))
41 
42 typedef struct {
43     unsigned short	imagic;		/* stuff saved on disk . . */
44     unsigned short 	type;
45     unsigned short 	dim;
46     unsigned short 	xsize;
47     unsigned short 	ysize;
48     unsigned short 	zsize;
49     unsigned long 	min_color;
50     unsigned long 	max_color;
51     unsigned long	wastebytes;
52     char 		name[80];
53     unsigned long	colormap;
54 
55     long 		file;		/* stuff used in core only */
56     unsigned short 	flags;
57     short		dorev;
58     short		x;
59     short		y;
60     short		z;
61     short		cnt;
62     unsigned short	*ptr;
63     unsigned short	*base;
64     unsigned short	*tmpbuf;
65     unsigned long	offset;
66     unsigned long	rleend;		/* for rle images */
67     unsigned long	*rowstart;	/* for rle images */
68     long		*rowsize;	/* for rle images */
69 } IMAGE;
70 
71 #endif				/* gdevsgi_INCLUDED */
72