Debian Codegraph @

converter/other/rast.h

raw
1 /* rast.h - header file for Sun raster files
2 **
3 ** The format of a Sun raster file is as follows. First, a struct
4 ** rasterfile. Note the 32-bit magic number at the beginning; this
5 ** identifies the file type and lets you figure out whether you need
6 ** to do little-endian / big-endian byte-swapping or not. (The PBMPLUS
7 ** implementation does not do byte-swapping; instead, it reads all
8 ** multi-byte values a byte at a time.)
9 **
10 ** After the struct is an optional colormap. If ras_maptype is RMT_NONE,
11 ** no map is present; if it's RMT_EQUAL_RGB then the map consists of
12 ** three unsigned-char arrays ras_maplength long, one each for r g and b.
13 ** I don't know what RMT_RAW means. Black and white bitmaps are stored
14 ** as ras_maptype == RMT_NONE and ras_depth == 1, with the bits stored
15 ** eight to a byte MSB first.
16 **
17 ** Finally comes the image data. If ras_type is RT_OLD or RT_STANDARD,
18 ** the data is just plain old uncompressed bytes, padded out to a multiple
19 ** of 16 bits in each row. If ras_type is RT_BYTE_ENCODED, a run-length
20 ** compression scheme is used: an escape-byte of 128 indicates a run;
21 ** the next byte is a count, and the one after that is the byte to be
22 ** replicated. The one exception to this is if the count is 1; then
23 ** there is no third byte in the packet, it means to put a single 128
24 ** in the data stream.
25 */
26
27 #ifndef RAST_H_INCLUDED
28 #define RAST_H_INCLUDED
29
30 #define PIX_ERR -1
31
32 struct rasterfile {
33 long ras_magic;
34 #define RAS_MAGIC 0x59a66a95
35 long ras_width;
36 long ras_height;
37 long ras_depth;
38 long ras_length;
39 long ras_type;
40 #define RT_OLD 0 /* Raw pixrect image in 68000 byte order */
41 #define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */
42 #define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */
43 #define RT_FORMAT_RGB 3 /* XRGB or RGB instead of XBGR or BGR */
44 #define RT_FORMAT_TIFF 4 /* tiff <-> standard rasterfile */
45 #define RT_FORMAT_IFF 5 /* iff (TAAC format) <-> standard rasterfile */
46 #define RT_EXPERIMENTAL 0xffff /* Reserved for testing */
47 long ras_maptype;
48 #define RMT_NONE 0
49 #define RMT_EQUAL_RGB 1
50 #define RMT_RAW 2
51 long ras_maplength;
52 };
53
54 struct pixrectops {
55 int (*pro_rop)();
56 int (*pro_stencil)();
57 int (*pro_batchrop)();
58 int (*pro_nop)();
59 int (*pro_destroy)();
60 int (*pro_get)();
61 int (*pro_put)();
62 int (*pro_vector)();
63 struct pixrect* (*pro_region)();
64 int (*pro_putcolormap)();
65 int (*pro_getcolormap)();
66 int (*pro_putattributes)();
67 int (*pro_getattributes)();
68 };
69
70 struct pr_size {
71 int x, y;
72 };
73
74 struct pr_pos {
75 int x, y;
76 };
77
78 struct pixrect {
79 struct pixrectops* pr_ops;
80 struct pr_size pr_size;
81 int pr_depth;
82 struct mpr_data* pr_data; /* work-alike only handles memory pixrects */
83 };
84
85 struct mpr_data {
86 int md_linebytes;
87 unsigned char* md_image; /* note, byte not short -- avoid pr_flip() */
88 struct pr_pos md_offset;
89 short md_primary;
90 short md_flags;
91 };
92
93 typedef struct {
94 int type;
95 int length;
96 unsigned char* map[3];
97 } colormap_t;
98
99 /* And the routine definitions. */
100
101 struct pixrect *
102 mem_create(int const w,
103 int const h,
104 int const depth);
105
106 void
107 mem_free(struct pixrect * const p);
108
109 int
110 pr_dump(struct pixrect * const p,
111 FILE * const out,
112 colormap_t * const colormap,
113 int const type,
114 int const copy_flag);
115
116 int
117 pr_load_header(FILE * const in,
118 struct rasterfile * const hP);
119
120 int
121 pr_load_colormap(FILE * const in,
122 struct rasterfile * const hP,
123 colormap_t * const colormap);
124
125 struct pixrect *
126 pr_load_image(FILE * const in,
127 struct rasterfile * const hP,
128 colormap_t * const colormap);
129
130 #endif