pro chkvwimg, rawimg, binned_data, cl, out, nerr
;
; This procedure creates a 1024x1024 byte array (out) from  the medium-l
; list (cl).   The array is set to value at each address in the address lists
; if value is 0, the rest of the array is set to 255; otherwise the rest of
; the array is set to zero.

out = intarr(172,172)
; out(0:*) = 0
; if (value eq 0) then out(0:*) = 255
l=n_elements(cl)
j = 0L
total_errs = 0
line_errs = 0
p = 0
nal = cl(2)
print,nal
table_start = '7000'XL
xvec_offset = (long(cl(16) and 'ffff'x) + (long(cl(17) and 'ffff'x) * '10000'x)) - table_start
nx = cl(18)
yvec_offset = (long(cl(19) and 'ffff'x) + (long(cl(20) and 'ffff'x) * '10000'x)) - table_start
ny = cl(21)
xvec = long(bl(xvec_offset:xvec_offset+nx-1))
yvec = long(bl(yvec_offset:yvec_offset+ny-1))
wt_table = lonarr(nx, ny)
for ix = 0, nx-1 do begin
    wt_table (0, ix) = ishft ((xvec(ix) * yvec), -15)
endfor

for i=0,nal-1  do begin
  nextal = (i)*10+22
  ix = (long(cl(nextal)) and 65535) + (long(cl(nextal+1)) * 65536L)
  ixr = ix - table_start
  nent = cl(nextal + 2)
  ixre = ixr + nent*2 - 1
;  print,"New List"
  print, nextal,ix,ixr,table_start,nent,ixre,format='(i6,5z10)'
  for j = ixr,ixre,2 do begin
    add = long(cl(j) and 'ffff'x) + (long(cl(j+1) and 'ffff'x) * 65536L)
     r = add / 1024
     c = add mod 1024
    ; print,r,c,format
    out(c/6,r/6) = binned_data(p)
    p = p + 1
  end
end
return
end
