THEN {
rWRef: AIS.WRef ← AIS.OpenWindow[rAis, aisY, aisY+aisH-1, aisX, aisX+aisW-1];
gWRef: AIS.WRef ← AIS.OpenWindow[gAis, aisY, aisY+aisH-1, aisX, aisX+aisW-1];
bWRef: AIS.WRef ← AIS.OpenWindow[bAis, aisY, aisY+aisH-1, aisX, aisX+aisW-1];
w: INTEGER ← rWRef.lastPixel-rWRef.firstPixel+1;
h: INTEGER ← rWRef.lastScan-rWRef.firstScan+1;
rSampleBuf: SampleBuffer ← ImagerSample.ObtainScratchSamples[w];
gSampleBuf: SampleBuffer ← ImagerSample.ObtainScratchSamples[w];
bSampleBuf: SampleBuffer ← ImagerSample.ObtainScratchSamples[w];
rMap: RasterSampleMap ← ImagerSample.NewSampleMap[[[0, 0], [1, w]], 8, 8*w];
gMap: RasterSampleMap ← ImagerSample.NewSampleMap[[[0, 0], [1, w]], 8, 8*w];
bMap: RasterSampleMap ← ImagerSample.NewSampleMap[[[0, 0], [1, w]], 8, 8*w];
rgMap: SampleMap ← CtBasic.GetRedGrn[maps[0].map];
rAISBuf: AIS.Buffer ← LineBufferFromRasterSampleMap[rMap];
gAISBuf: AIS.Buffer ← LineBufferFromRasterSampleMap[gMap];
bAISBuf: AIS.Buffer ← LineBufferFromRasterSampleMap[bMap];
shift: Vec ← [0, 0];
SELECT TRUE FROM
center => shift ← [(h-maps.size.s)/2, (w-maps.size.f)/2];
placement # NIL => {
rgMap ← ImagerSample.Shift[rgMap, [-placement.yBottom, -2*placement.xLeft]];
maps[1].map ←ImagerSample.Shift[maps[1].map,[-placement.yBottom,-placement.xLeft]];
};
ENDCASE;
IF shift.f < 0 THEN {
rgMap ← ImagerSample.Shift[rgMap, [0, 2*shift.f]];
maps[1].map ← ImagerSample.Shift[maps[1].map, [0, shift.f]];
shift.f ← 0;
};
IF shift.s < 0 THEN {
rgMap ← ImagerSample.Shift[rgMap, [shift.s, 0]];
maps[1].map ← ImagerSample.Shift[maps[1].map, [shift.s, 0]];
shift.s ← 0;
};
FOR i: INT IN [0..MIN[h, maps.size.s]) DO
y: NAT ← i+shift.s;
TRUSTED {AIS.UnsafeReadLine[rWRef, rAISBuf, y]}; -- file to rMap (rAISBuf)
TRUSTED {AIS.UnsafeReadLine[gWRef, gAISBuf, y]}; -- file to gMap (gAISBuf)
TRUSTED {AIS.UnsafeReadLine[bWRef, bAISBuf, y]}; -- file to bMap (bAISBuf)
ImagerSample.GetSamples[rMap, [0, shift.f],, rSampleBuf, 0, maps.size.f]; -- rSampleBuf
ImagerSample.GetSamples[gMap, [0, shift.f],, gSampleBuf, 0, maps.size.f]; -- gSampleBuf
ImagerSample.GetSamples[bMap, [0, shift.f],, bSampleBuf, 0, maps.size.f]; -- bSampleBuf
Write the red, starting at 0, with delta.f = 2, thus writing the even bytes:
ImagerSample.PutSamples[rgMap, [i+maps.y, 2*maps.x], [0, 2], rSampleBuf, 0, maps.w];
Write the green, starting at 1, with delta.f = 2, thus writing the odd bytes:
ImagerSample.PutSamples[rgMap, [i+maps.y, 1+2*maps.x], [0, 2], gSampleBuf, 0, maps.w];
Write the blue:
ImagerSample.Transfer[maps[1].map, ImagerSample.Shift[bMap, [maps.y+i, maps.x+-shift.f]]];
Process.CheckForAbort[];
ENDLOOP;
AIS.CloseWindow[rWRef];
AIS.CloseWindow[gWRef];
AIS.CloseWindow[bWRef];
ImagerSample.ReleaseScratchSamples[rSampleBuf];
ImagerSample.ReleaseScratchSamples[gSampleBuf];
ImagerSample.ReleaseScratchSamples[bSampleBuf];
TRUSTED {
ImagerSample.ReleaseDescriptor[rMap];
ImagerSample.ReleaseDescriptor[gMap];
ImagerSample.ReleaseDescriptor[bMap];
ImagerSample.ReleaseDescriptor[rgMap];
};
}