|
Example n.4 - Multiple Output
|
Previous Top Next |
| //test if image is monochrome
|
| nBits:=ImgGetBitsPixel(_CurrentImage);
|
|
|
| //if it's not monochrome,
|
| if nBits=8 then
|
| begin
|
| // copying the whole image
|
| BinaryImage:=ImgCopy(_CurrentImage,0,0,0,0);
|
|
|
| //thresholding
|
| ImgThreshold(BinaryImage,127);
|
|
|
| //saving
|
| NewFileName:=ExtractFilePath(_CurrentOutputFile)+'\Mono'+ExtractFileName(_CurrentOutputFile);
|
| tipo:=ExtractFileExt(_CurrentOutputFile);
|
| if tipo='.tif' then ImgSaveAsTif(BinaryImage,NewFileName)
|
| else if tipo='.jpg' then ImgSaveAsJpg(BinaryImage,NewFileName)
|
| else if tipo='.png' then ImgSaveAsPng(BinaryImage,NewFileName)
|
| else if tipo='.bmp' then ImgSaveAsBmp(BinaryImage,NewFileName)
|
| else ApplicationLog(_CurrentAgent,'Error: '+tipo+' format not supported in output.');
|
|
|
| //deleting
|
| ImgDelete(BinaryImage);
|