1 |
/* RCSid $Id: idmap.h,v 2.1 2019/07/26 16:18:06 greg Exp $ */ |
2 |
/* |
3 |
* Definitions and delcarations for loading identifier maps |
4 |
* |
5 |
* Include after stdio.h |
6 |
* Includes resolu.h |
7 |
*/ |
8 |
|
9 |
#ifndef _RAD_IDMAP_H_ |
10 |
#define _RAD_IDMAP_H_ |
11 |
|
12 |
#include "resolu.h" |
13 |
|
14 |
#ifdef __cplusplus |
15 |
extern "C" { |
16 |
#endif |
17 |
|
18 |
#define IDMAP8FMT "8-bit_indexed_name" |
19 |
#define IDMAP16FMT "16-bit_indexed_name" |
20 |
#define IDMAP24FMT "24-bit_indexed_name" |
21 |
#define IDMAPFMT "*-bit_indexed_name" |
22 |
|
23 |
#define HF_HEADOUT 0x2 /* copy header to stdout */ |
24 |
#define HF_RESOUT 0x8 /* copy resolution */ |
25 |
#define HF_STDERR 0x10 /* report errors to stderr */ |
26 |
|
27 |
/* Structure for reading identifier maps */ |
28 |
typedef struct { |
29 |
FILE *finp; /* input file pointer */ |
30 |
long dstart; /* start of data */ |
31 |
long curpos; /* current input position */ |
32 |
RESOLU res; /* input resolution */ |
33 |
int bytespi; /* 1, 2, or 3 bytes per index */ |
34 |
int nids; /* ID count */ |
35 |
int *idoffset; /* offsets to identifiers */ |
36 |
char idtable[1]; /* nul-terminated ID strings */ |
37 |
} IDMAP; |
38 |
|
39 |
/* Get indexed ID */ |
40 |
#define mapID(mp,i) ( (i) >= (mp)->nids ? (char *)NULL : \ |
41 |
(mp)->idtable+(mp)->idoffset[i] ) |
42 |
|
43 |
/* Open ID map file for reading, copying info to stdout based on hflags */ |
44 |
extern IDMAP *idmap_ropen(const char *fname, int hflags); |
45 |
|
46 |
/* Read the next ID index from input */ |
47 |
extern int idmap_next_i(IDMAP *idmp); |
48 |
|
49 |
/* Read the next ID from input */ |
50 |
extern const char *idmap_next(IDMAP *idmp); |
51 |
|
52 |
/* Seek to a specific pixel position in ID map */ |
53 |
extern int idmap_seek(IDMAP *idmp, int x, int y); |
54 |
|
55 |
/* Read ID at a pixel position */ |
56 |
extern const char *idmap_pix(IDMAP *idmp, int x, int y); |
57 |
|
58 |
/* Close ID map and free resources */ |
59 |
extern void idmap_close(IDMAP *idmp); |
60 |
|
61 |
#ifdef __cplusplus |
62 |
} |
63 |
#endif |
64 |
#endif /* _RAD_IDMAP_H_ */ |