Transforms the three AIS files red,green and blue into the single AIS file: rgb using the user supplied map procedure and applying Floyd-Steinberg error distribution.
redString: LONG STRING ← [30];
greenString: LONG STRING ← [30];
blueString: LONG STRING ← [30];
rgbString: LONG STRING ← [30];
redFD, greenFD, blueFD, rgbFD:AIS.FRef;
temp, this, next:PixelBuf; -- 'this' holds current line's data, 'next - the one below
r:AIS.RasterPart;
redW, blueW, greenW, rgbW:AIS.WRef;
scan, top, bottom, left, right:CARDINAL;
Open the input files and get hold of the raster info. for use in generating the rgb ouput file
ConvertUnsafe.AppendRope[redString, redFn];
ConvertUnsafe.AppendRope[greenString, greenFn];
ConvertUnsafe.AppendRope[blueString, blueFn];
redFD ← AIS.OpenFile[redString];
redW ← AIS.OpenWindow[redFD];
greenFD ← AIS.OpenFile[greenString];
greenW ← AIS.OpenWindow[greenFD];
blueFD ← AIS.OpenFile[blueString];
blueW ← AIS.OpenWindow[blueFD];
Create the output file
AIS.ReadRaster[redFD, @r];
ConvertUnsafe.AppendRope[rgbString, rgbFn];
[] ← AIS.DeleteFile[rgbString];
rgbFD ← AIS.CreateFile[name:rgbString, raster:@r, overwrite:TRUE];
rgbW ← AIS.OpenWindow[rgbFD];
Create two working buffers for scan lines
[top, bottom, left, right] ← AIS.GetWindowParams[redW];
this ← NEW[PixelBufRec[right+2]]; -- make it a bit bigger to catch error propogation
next ← NEW[PixelBufRec[right+2]];
initialise the 'next' buffer with the first scan line
ReadRGB[redW, greenW, blueW, left, right, 1, next];
FOR scan IN [top..bottom]
DO
advance the scan line buffers to the next line
temp ← this; this ← next; next ← temp;
IF scan < bottom
THEN
ReadRGB[redW, greenW, blueW, left, right, scan+1, next];
SquashScan[this, next, left,right, map];
Writergb[rgbW, left, right, scan, this];
ENDLOOP;
AIS.CloseWindow[redW];
AIS.CloseWindow[blueW];
AIS.CloseWindow[greenW];
AIS.CloseWindow[rgbW];
AIS.CloseFile[redFD];
AIS.CloseFile[blueFD];
AIS.CloseFile[greenFD];
AIS.CloseFile[rgbFD];
};
redString: LONG STRING ← [30];
greenString: LONG STRING ← [30];
blueString: LONG STRING ← [30];
rgbString: LONG STRING ← [30];
redFD, greenFD, blueFD, rgbFD:AIS.FRef;
raster:AIS.RasterPart;
redW, blueW, greenW, rgbW:AIS.WRef;
scan, pixel, top, bottom, left, right:CARDINAL;
r,g,b:CARDINAL;
Open the input file and get hold of the raster info. for use in generating the ouput files
ConvertUnsafe.AppendRope[redString, redFn];
ConvertUnsafe.AppendRope[greenString, greenFn];
ConvertUnsafe.AppendRope[blueString, blueFn];
ConvertUnsafe.AppendRope[rgbString, rgbFn];
rgbFD ← AIS.OpenFile[name:rgbString];
rgbW ← AIS.OpenWindow[rgbFD];
AIS.ReadRaster[rgbFD, @raster];
[] ← AIS.DeleteFile[redString];
redFD ← AIS.CreateFile[name:redString, raster:@raster, overwrite:TRUE];
redW ← AIS.OpenWindow[redFD];
[] ← AIS.DeleteFile[greenString];
greenFD ← AIS.CreateFile[name:greenString, raster:@raster, overwrite:TRUE];
greenW ← AIS.OpenWindow[greenFD];
[] ← AIS.DeleteFile[blueString];
blueFD ← AIS.CreateFile[name:blueString, raster:@raster, overwrite:TRUE];
blueW ← AIS.OpenWindow[blueFD];
[top, bottom, left, right] ← AIS.GetWindowParams[rgbW];
FOR scan IN [top..bottom]
DO
FOR pixel
IN [left..right]
DO
[r,g,b] ← unMap[AIS.ReadSample[rgbW, scan, pixel]];
AIS.WriteSample[redW, r, scan, pixel];
AIS.WriteSample[greenW, g, scan, pixel];
AIS.WriteSample[blueW, b, scan, pixel];
ENDLOOP;
ENDLOOP;
AIS.CloseWindow[redW];
AIS.CloseWindow[blueW];
AIS.CloseWindow[greenW];
AIS.CloseWindow[rgbW];
AIS.CloseFile[redFD];
AIS.CloseFile[blueFD];
AIS.CloseFile[greenFD];
AIS.CloseFile[rgbFD];
};