macro 'Color Merge Two Images'; { Merges a "red" image and a "green" image to create a composite color image by creating a temporary 24-bit image and converted to 8-bits. } var i,w1,w2,h1,h2,rgb:integer; begin Requires(1.50); SaveState; if nPics<>2 then begin PutMessage('This macro operates on exactly two images.'); exit; end; SelectPic(1); GetPicSize(w1,h1); SelectPic(2); GetPicSize(w2,h2); if (w1<>w2) or (h1<>h2) then begin PutMessage('The two images must have the same width and height.'); exit; end; SetNewSize(w1,h2); SetBackground(255); MakeNewStack('RGB'); AddSlice; AddSlice; rgb:=PicNumber; SelectPic(1); SelectAll; Copy; SelectPic(rgb); SelectSlice(1); Paste; Invert; SelectPic(2); SelectAll; Copy; SelectPic(rgb); SelectSlice(2); Paste; Invert; RGBToIndexed('Custom'); SelectPic(rgb); Dispose; RestoreState; end; macro 'Color Merge Two Stacks'; { Merges a "red" stack and a "green" stack to create a new composite color stack. } var i,w1,w2,h1,h2,d1,d2,d3:integer; rgb,merged:integer; begin Requires(1.50); SaveState; 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; if (d1=0) or (d2=0) then begin PutMessage('Both images must be stacks.'); exit; end; if d1>=d2 then d3:=d2 else d3:=d1; if (w1<>w2) or (h1<>h2) then begin PutMessage('The two stacks must have the same width and height.'); exit; end; SetNewSize(w1,h2); SetBackground(255); MakeNewStack('RGB'); AddSlice; AddSlice; rgb:=PicNumber; SetPalette('System'); MakeNewStack('Merged'); merged:=PicNumber; for i:=1 to d3 do begin SelectPic(1); SelectSlice(i); SelectAll; Copy; {DeleteSlice;} SelectPic(rgb); SelectSlice(1); SelectAll; Paste; Invert; SelectPic(2); SelectSlice(i); SelectAll; Copy; {DeleteSlice;} SelectPic(rgb); SelectSlice(2); SelectAll; Paste; Invert; SelectPic(rgb); RGBToIndexed('System'); SelectAll; Copy; Dispose; SelectPic(merged); Paste; if i<>d3 then AddSlice; end; SelectPic(rgb); Dispose; { SelectPic(1); Dispose; SelectPic(1); Dispose; } RestoreState; end; macro 'RGB to Indexed'; begin RGBToIndexed('Custom LUT'); end;