forked from Dwayne-Phillips/CIPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcips.h
executable file
·240 lines (198 loc) · 5.83 KB
/
cips.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/************************************************************
*
* file d:\cips\cips.h
*
* Functions: This file contains no functions. It
* contains declarations of the data structures used
* by the C Image Processing Systems CIPS.
*
* Purpose:
* To declare data structures.
*
* Modifications:
* June 1990 = created
*
* February 2016 - in this postmodern world,
* on a Mac with OS X 10.10...
* Longs are 8 bytes
* INTS are 4 bytes
* FLOATS are 4 bytes
*
* You have to declare some functions before you use them.
* See end of this file.
*
*
*
**********************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <math.h>
#include <string.h>
/****#include <graph.h>*****/
/***** #include <io.h> *****/
/**** #include <dos.h> ****/
/*** #include <malloc.h> ****/
/**** #include <sys\types.h> ****/
/**** #include <sys\stat.h> ****/
#define MAX_NAME_LENGTH 80
#define ROWS 100
#define COLS 100
#define GRAY_LEVELS 255
#define PREWITT 1
#define PEAK_SPACE 50
#define PEAKS 30
#define KIRSCH 2
#define SOBEL 3
#define STACK_SIZE 40000
#define STACK_FILE_LENGTH 500
#define FORGET_IT -50
#define STACK_FILE "c:stack"
/*********************************************
*
* N O T E
* P O R T A B I L I T Y I S S U E
*
* The next two statements help port the
* system to non-Microsoft C compilers.
*
* If you use Microsoft C, then you should
* #define MSC 1 and
* #undef OTHERC
*
* If you are using another C compiler or
* are porting this to another type of
* machine, then you should
* #undef MSC
* #define OTHERC 1
*
* Now you need to make changes in mymsc.c
*
**********************************************/
/*******#define MSC 1******/
/*******#undef OTHERC******/
#define OTHERC 1
#undef MSC
/*********************************************
*
* N O T E
* P O R T A B I L I T Y I S S U E
*
* Define the Microsoft contants. If you
* are using OTHERC, then just put numbers
* there to hold a place.
*
*********************************************/
#ifdef MSC
#define VRES16COLOR _VRES16COLOR
#define ERESCOLOR _ERESCOLOR
#define MAXCOLORMODE _MAXCOLORMODE
#define HRESBW _HRESBW
#define MRES4COLOR _MRES4COLOR
#define TEXTC80 _TEXTC80
#define GCLEARSCREEN _GCLEARSCREEN
#endif
#ifdef OTHERC
#define VRES16COLOR 1
#define ERESCOLOR 1
#define MAXCOLORMODE 1
#define HRESBW 1
#define MRES4COLOR 1
#define TEXTC80 1
#define GCLEARSCREEN 1
#endif
/**************************************************
*
* The following struct defines the information
* you need to read from the tiff file
* header.
*
***************************************************/
struct tiff_header_struct{
short lsb;
long bits_per_pixel;
long image_length;
long image_width;
long strip_offset;
};
/**************************************************
*
* The following struct defines the information
* you need to read from the bmp file
* header.
*
***************************************************/
struct bmpfileheader{
unsigned short filetype;
unsigned long filesize;
short reserved1;
short reserved2;
unsigned long bitmapoffset;
};
struct bitmapheader{
unsigned long size;
long width;
long height;
unsigned short planes;
unsigned short bitsperpixel;
unsigned long compression;
unsigned long sizeofbitmap;
unsigned long horzres;
unsigned long vertres;
unsigned long colorsused;
unsigned long colorsimp;
};
struct ctstruct{
unsigned char blue;
unsigned char green;
unsigned char red;
};
/*********************************************
*
* The following four unions are used
* to put the bytes from the header
* into either an integer or a floating
* point number.
*
**********************************************/
union short_char_union{
short s_num;
char s_alpha[2];
};
union int_char_union{
int i_num;
char i_alpha[4];
};
union long_char_union{
long l_num;
char l_alpha[8];
};
union float_char_union{
float f_num;
char f_alpha[4];
};
union ushort_char_union{
short s_num;
char s_alpha[2];
};
union uint_char_union{
int i_num;
char i_alpha[4];
};
union ulong_char_union{
long l_num;
char l_alpha[8];
};
/* for some reason, February 2016, you have to declare these two */
/* functions before you use them. */
short** allocate_image_array(long, long);
int free_image_array(short **, long);
int calculate_pad(long);
/*********
int extract_long_from_buffer(char *, long, long, long *);
int extract_ulong_from_buffer(char *, long, long, unsigned long *);
**********/
int is_a_bmp(char *);
int is_a_tiff(char *);
int print_tiff_header(struct tiff_header_struct);
int read_bmp_file_header(char *filename, struct bmpfileheader *);