{This file contains macros that Splices Stacks Together.} procedure CheckForStack; begin if nPics=0 then begin PutMessage('This macro requires a stack.'); exit; end; if nSlices=0 then begin PutMessage('This window is not a stack.'); exit end; end; macro 'CheckLength'; begin SelectPic(1); PutMessage('Number of Slices: ',nSlices); end; macro 'Splice Two Stacks'; { Splices two stacks(w1xh1xd1 and w2xh2xd2) to create a new d1+d2 x max(h1,h2) x max(w1,w2) stack.} var i,w1,w2,w3,h1,h2,h3,d1,d2,d3:integer; begin SaveState; SetBackgroundColor(0); if nPics<>2 then begin PutMessage('This macro operates on exactly two stacks.'); exit; end; SelectPic(1); GetPicSize(w1,h1); d1:=nSlices; SelectPic(2); GetPicSize(w2,h2); d2:=nSlices; d3:=d1+d2; {*Total New Stack Size*} if d3=0 then begin PutMessage('Both images must be stacks.'); exit; end; if w1>=w2 then w3:= w1 else w3:=w2; if h1>=h2 then h3:=h1 else h3:=h2; SetNewSize(w3,h3); MakeNewStack('Merged'); for i:=1 to d1 do begin SelectPic(1); SelectSlice(1); SelectAll; Copy; DeleteSlice; SelectPic(3); MakeRoi(0,0,w1,h1); Paste; AddSlice; end; for i:=1 to d2 do begin SelectPic(2); SelectSlice(1); SelectAll; Copy; DeleteSlice; SelectPic(3); MakeRoi(0,0,w2,h2); Paste; if i2 then begin PutMessage('This macro operates on exactly two stacks.'); exit; end; SelectPic(1); GetPicSize(w1,h1); d1:=nSlices; SelectPic(2); GetPicSize(w2,h2); d2:=nSlices; d3:=d1+d2; if d3=0 then begin PutMessage('Both images must be stacks.'); exit; end; if w1>=w2 then picn:=1 else picn:=2; if w1>=w2 then opic:=2 else opic:=1; if picn=1 then nlength:=d2 else nlength:=d1; if picn=1 then olength:=d1 else olength:=d2; SelectPic(picn); SelectSlice(olength); for i:=1 to nlength do begin SelectPic(opic); SelectSlice(1); SelectAll; Copy; DeleteSlice; SelectPic(picn); AddSlice; MakeRoi(0,0,w1,h1); Paste; end; SelectPic(opic); Dispose; RestoreState; end;