-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmaincp.c
executable file
·139 lines (117 loc) · 3.48 KB
/
maincp.c
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
/***********************************************
*
* file maincp.c
*
* Functions: This file contains
* main
*
* Purpose:
* This file contains the main calling
* routine for a program which
* cuts a piece from one image and pastes
* it into another.
*
* External Calls:
* imageio.c - create_image_file
* read_image_array
* write_image_array
* get_image_size
* allocate_image_array
* free_image_array
* cutp.c - paste_image_piece
* check_cut_and_paste_limits
*
* Modifications:
* 8 April 1992 - created
* 12 August 1998 - modified to work on
* entire image array at once.
* 18 September 1998 - modified to work with
* all I O routines in imageio.c.
*
*************************************************/
#include "cips.h"
int does_not_exist();
int get_image_size();
int read_image_array();
int free_image_array();
int check_cut_and_paste_limits();
int paste_image_piece();
int write_image_array();
int free_image_array();
int main(argc, argv)
int argc;
char *argv[];
{
char name1[80], name2[80];
int i, is_ok, il1, ie1, ll1, le1,
il2, ie2, ll2, le2;
long length1, length2, width1, width2;
short **the_image, **out_image;
/******************************************
*
* Interpret the command line parameters.
*
*******************************************/
if(argc != 9){
printf(
"\n"
"\n usage: maincp in-file out_file "
"in-il in-ie in-ll in-le out-il out-ie"
"\n"
"\n The image portion is pasted from the "
"\n in-file into the out-file"
"\n");
exit(0);
}
strcpy(name1, argv[1]);
strcpy(name2, argv[2]);
if(does_not_exist(name1)){
printf("\nERROR input file %s does not exist",
name1);
exit(0);
}
if(does_not_exist(name2)){
printf("\nERROR input file %s does not exist",
name2);
exit(0);
}
il1 = atoi(argv[3]);
ie1 = atoi(argv[4]);
ll1 = atoi(argv[5]);
le1 = atoi(argv[6]);
il2 = atoi(argv[7]);
ie2 = atoi(argv[8]);
/******************************************
*
* Read the input image sizes, allocate
* the image array and read the image
* for both images.
*
******************************************/
get_image_size(name1, &length1, &width1);
get_image_size(name2, &length2, &width2);
the_image = allocate_image_array(length1, width1);
out_image = allocate_image_array(length2, width2);
read_image_array(name1, the_image);
read_image_array(name2, out_image);
/*************************
*
* Paste
*
**************************/
check_cut_and_paste_limits(
il1, ie1,
ll1, le1,
il2, ie2,
length1, width1,
length2, width2,
&is_ok);
printf("\nMAIN> is_ok=%d", is_ok);
if(is_ok)
paste_image_piece(the_image, out_image,
il1, ie1, ll1, le1,
il2, ie2);
write_image_array(name2, out_image);
free_image_array(out_image, length2);
free_image_array(the_image, length1);
} /* ends main */