pro ext1ffi_buff, ref, rec1, sxtos2, img, nx, ny, istcol, iencol, ix, iy, qfimg, next
;
;
;
ref_struct, ref, dpos1, dpos2, sxtos1, sxtos2, sxtos3, stat1
;
sxttelem	= mask(rec1(sxtos2, 16), 6, 2)
;
if (sxttelem eq 1) then begin 
    img0 = rec1(16:*, *)		;drop first 16 bytes of each minor frame
    img0 = byte(img0,0, 16,8,64)	;16x8 by 64 minor frames
    img0 = img0(istcol:iencol, *, *)
    ;
    ninmf = (iencol-istcol+1)*8*64	;1024 or 4096
    nlin = ninmf / nx			;for 1024, nlin = 1,2 or  4 -1x1,2x2,4x4
					;for 4096, nlin = 4,8 or 16
    img0 = byte(img0,0, nx,nlin)
    ;
    img(ix, iy) = img0
    ;
    ix = 0				;always is zero
    iy = iy + nlin
end
;
qfimg = 0
if ((iy eq ny) and (ix eq 0)) then qfimg = 1	;full image
next = next + n_elements(img0)
;
end
