Example n.3 - Redirected Output |
Top Previous Next |
In this example we'll slightly modify preceding example for showing how redirecting the output.
// retrieving number of bits/pixel nBitsPixel:=ImgGetBitsPixel(_CurrentImage);
// extracting file name from full path fileName:=ExtractFileName(_CurrentOutputFile);
// extracting directory from full path path:=ExtractFilePath(_CurrentOutputFile);
//redirecting output if nBitsPixel=1 then begin //monochrome image _CurrentOutputFile:= path+'Mono\'+filename; ApplicationLog('Redirecting '+_CurrentInputFile+' to ' +_CurrentOutputFile); end else if nBitsPixel=8 then begin //grayscale image _CurrentOutputFile:= path+'Gray\'+filename; ApplicationLog('Redirecting '+_CurrentInputFile+' to ' +_CurrentOutputFile);
end else begin //color image _CurrentOutputFile:= path+'Color\'+filename; ApplicationLog('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. |