Thanks Nigel for your feedback,
Here is my solution if any one interested:
// first check if the image file can be loaded
if not Image1.IO.ParamsFromFile( fileName, True ) then begin
ShowMessage('File: '+fileName+' is corrupt. Please write it down.');
end else begin
// the image can be loaded, but may be truncated
Image1.IO.LoadFromFile(fileName);
if chkAutoFit.Checked then
Image1.Fit;
Image1.SelectionBase := iesbBitmap;
// select a lower right square of the image
Image1.Select(Image1.fBitmap.Width - 100, Image1.fBitmap.Height - 100,
Image1.fBitmap.Width, Image1.fBitmap.Height);
// save it in IEBitmap object
Image1.CopySelectionToIEBitmap(bmp1);
// get the dominant color which should be gray
colorPercentage := ImageEnProc1.GetDominantColor(cl);
// if 90% of the color is gray
if (cl.r=128) and (cl.g=128) and (cl.b=128) and
(colorPercentage>90.0) then begin
ShowMessage('Bad image: '+fileName);
end;
end;
You need TImageEnView, ImageEnProc
Maybe you can do everything non-visually. But this is just my solution.
Enjoy.
-----------------
3 Monitors
Windows 10
Delphi 2007
ImageEn v.8.3