//redirecting output
if nBitsPixel=1 then
begin
//monochrome image
_CurrentOutputFile:= path+'Mono'+filename;
ApplicationLog(_CurrentAgent,'Redirecting '+_CurrentInputFile+' to ' +_CurrentOutputFile);
end
else if nBitsPixel=8 then
begin
//grayscale image
_CurrentOutputFile:= path+'Gray'+filename;
ApplicationLog(_CurrentAgent,'Redirecting '+_CurrentInputFile+' to ' +_CurrentOutputFile);
end
else
begin
//color image
_CurrentOutputFile:= path+'Color'+filename;
ApplicationLog(_CurrentAgent,'Redirecting '+_CurrentInputFile+' to ' +_CurrentOutputFile);
end;
Looking at code details, we can easily understand that we reached the redirection target, modifying the output file name. We've extracted the current path and name from _CurrentOutputFile , and according to image color characteristic, we have added the prefix either 'Mono' or 'Gray' or 'Color'. We can use similar technique for changing output directory and path: this is very useful when we want to stress errors or anomalies during batch processing, putting the file that shows these problems into a separated directory or marking it with a prefix or a suffix.