aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/ranges/rgunpack.gx
blob: 2b357ebb8d66df2fac71508e665c1b7e524f8967 (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<pkg/rg.h>

# RG_UNPACK -- Unpack a packed array.
#
# There is no checking on the size of the arrays.  The points in the
# unpacked array which are not covered by the packed array are left unchanged.
# The packed and unpacked arrays should not be the same.

procedure rg_unpack$t (rg, packed, unpacked)

pointer	rg					# Ranges
PIXEL	packed[ARB]				# Packed array
PIXEL	unpacked[ARB]				# Unpacked array

int	i, j, x1, x2, nx

begin
	if (rg == NULL)
	    call error (0, "Range descriptor undefined")

	j = 1
	do i = 1, RG_NRGS(rg) {
	    if (RG_X1(rg, i) < RG_X2(rg, i)) {
		x1 = RG_X1(rg, i)
		x2 = RG_X2(rg, i)
	    } else {
		x1 = RG_X2(rg, i)
		x2 = RG_X1(rg, i)
	    }

	    nx = x2 - x1 + 1
	    call amov$t (packed[j], unpacked[x1], nx)
	    j = j + nx
	}
end