aboutsummaryrefslogtreecommitdiff
path: root/pkg/obsolete/fixline.gx
blob: 8a6c3672c4ea1292c7c4027f111165d15908575a (plain) (blame)
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
include	<imhdr.h>
include	<imset.h>

$for (silrdx)

# FIXLINE -- Linearly interpolate lines across a region.

procedure fixline$t (image, x1, x2, y1, y2)

pointer	image				# Image pointer
int	x1, x2, y1, y2			# Region to be fixed

int	i, nx, ny
$if (datatype == x)
complex	f1, f2
$else $if (datatype == d)
double	f1, f2
$else
real	f1, f2
$endif $endif
pointer	a, b, c

pointer	imgs2$t(), imps2$t()

begin
	c = imps2$t (image, x1, x2, y1, y2)

	nx = x2 - x1 + 1
	ny = y2 - y1 + 1
	if (y1 == 1) {
	    a = imgs2$t (image, x1, x2, y2 + 1, y2 + 1)
	    do i = 1, ny
		call amov$t (Mem$t[a], Mem$t[c + (i - 1) * nx], nx)
	} else if (y2 == IM_LEN (image, 2)) {
	    a = imgs2$t (image, x1, x2,  y1 - 1, y1 - 1)
	    do i = 1, ny
		call amov$t (Mem$t[a], Mem$t[c + (i - 1) * nx], nx)
	} else {
	    call imseti (image, IM_NBUFS, 2)
	    a = imgs2$t (image, x1, x2, y1 - 1, y1 - 1)
	    b = imgs2$t (image, x1, x2, y2 + 1, y2 + 1)
	    do i = 1, ny {
		f2 = i / (ny + 1.)
		f1 = 1 - f2
		call awsu$t (Mem$t[a], Mem$t[b], Mem$t[c+(i-1)*nx], nx, f1, f2)
	    }
	}
end

$endfor