pro mkrwimg,bi,bl,out
;
; This procedure creates a 128X128 array (out) from  the rectangular bin
; list (bl).  The array contains a 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(128,128)
out(0:*) = 0
;if (value eq 0) then out(0:*) = 255
l=n_elements(bl)
j = 0L
total_errs = 0
line_errs = 0
tent = 0
nal = bl(2)
print,nal
table_start = '11200'XL
p = 0
for i=0,nal-1  do begin
  k = 0
  nextal = (i)*7+16
  ix = long(bl(nextal) and 65535) + long(bl(nextal+1) * 65536L)
  ixr = ix - table_start+512
  nent = bl(nextal + 2)
  ixre = ixr + nent*2 - 1
  tent = tent + nent
;  print,"New List"
  print, nextal,ix,ixr,ixre,nent,tent,format='(i6,5z10)'
  for j = ixr,ixre,2 do begin
    k = k + 1
    add = (long(bl(j)) and 65535) + ((long(bl(j+1)) and 65535) * 65536L)
     r = add / 1024
     c = add mod 1024
    ; print,r,c,format
    out(c/8,r/8) = bi(p)
    p = p + 1
  end
end
print,'p=',p
return
end
