pro makecrop,ci,cl,out,bg=bg
;
; This procedure creates a 1024x1024 array (out) from a cropped image (ci)
; and a crop list (cl).  Pixels outside the crop are set to value of 
; background keyword (bg) if specified; otherwise, 0.

out = intarr(1024,1024)
if (keyword_set(bg)) then out(0:*) = bg
l=n_elements(cl)
j = 0L
total_errs = 0
line_errs = 0
for i=16,l-1,3  do begin
  ix = long(cl(i) and 65535) + long(cl(i+1) * 65536L)
  len = long(cl(i+2))
  if (len lt 3) then goto ,listdone
  out(ix:ix+len) = ci(j:j+len)
  j = j+len+1
end
listdone:
return
end
