forked from Dwayne-Phillips/CIPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcutp.c
executable file
·130 lines (109 loc) · 3.07 KB
/
cutp.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
/***********************************************
*
* file cutp.c
*
* Functions: This file contains
* paste_image_piece
* check_cut_and_paste_limits
*
* Purpose:
* These functions paste a part of one
* image into another image.
*
* External Calls:
* none
*
* Modifications:
* 3 April 1992 - created
* 12 August 1998 - modified to work
* with an entire image array.
*
*************************************************/
#include "cips.h"
/*******************************************
*
* paste_image_piece(...
*
* This function pastes a rectangular
* piece of an image into another image.
* The rectangle to be pasted into the image
* is described by the il1, ie1, ll1, le1
* parameters for the input image.
*
*******************************************/
int paste_image_piece(the_image, out_image,
il1, ie1, ll1, le1,
il2, ie2)
int il1, ie1, ll1, le1, il2, ie2;
short **the_image,
**out_image;
{
int i, j, limit1, limit2;
limit1 = ll1-il1;
limit2 = le1-ie1;
for(i=0; i<limit1; i++){
for(j=0; j<limit2; j++){
out_image[il2+i][ie2+j] = the_image[il1+i][ie1+j];
}
}
return(1);
} /* ends paste_image_piece */
/*******************************************
*
* check_cut_and_paste_limits(...
*
* This function looks at the line and
* element parameters and ensures that they
* are not bigger than ROWS and COLS. If
* they are bigger, the last element or
* last line parameters are reduced.
*
*******************************************/
int check_cut_and_paste_limits(
il1, ie1,
ll1, le1,
il2, ie2,
image1_length,
image1_width,
image2_length,
image2_width,
is_ok)
int il1, ie1, ll1, le1, il2, ie2,
image1_length, image1_width,
image2_length, image2_width,
*is_ok;
{
int result = 1;
if( il1 < 0 ||
ie1 < 0){
printf("\nCheck> il1=%d ie1=%d", il1, ie1);
result = 0;
}
if( il2 < 0 ||
ie2 < 0){
printf("\nCheck> il2=%d ie2=%d", il2, ie2);
result = 0;
}
if(ll1 > image1_length){
printf("\nCheck> ll1=%d length=%d",
ll1, image1_length);
result = 0;
}
if(le1 > image1_width){
printf("\nCheck> le1=%d width=%d",
le1, image1_width);
result = 0;
}
if((il2+(ll1-il1)) > image2_length){
printf("\nCheck> il2=%d length=%d",
il2+(ll1-il1), image2_length);
result = 0;
}
if((ie2+(le1-ie1)) > image2_width){
printf("\nCheck> ie2=%d width=%d",
ie2+(le1-ie1), image2_width);
result = 0;
}
*is_ok = result;
return(1);
} /* ends check_cut_and_paste_limits */