Greetings All,
Delphi XE5
ImageEn 5.0.5
Code that has been working for years suddenly stops working.
I have not upgraded recently.
The line that it breaks on (near the end of the following code segment) is:
ImageEnMView1.MIO.Params[0].TIFF_Compression := ioTIFF_G4FAX;
Where "Params[0]" is now nil for some reason.
Following is the complete code I use for taking the front and back image of a check in any format (png, gif) and adding them together and saving them as one multi-page tif file
Can anyone tell me what may have happened?
procedure TfrmInterfaceFiservImport.AutoConvert(BypassImageLoading: Boolean);
procedure ProcessImage(Filename: String);
var
iPos: SmallInt;
sCDSFileName: String;
sFileName: String;
sOrigFrontImageFilename: String;
sOrigBackImageFilename: String;
begin
ClearInterface;
bFrontImageExists := False;
bBackImageExists := False;
sOrigFrontImageFilename := '';
sOrigBackImageFilename := '';
if ((FileName <> '.') and (FileName <> '..')) then
begin
if ExtractFileExt(FileName) <> '.ocf' then
begin
iPos := POS('.', FileName);
if iPos > 0 then
begin
sCDSFileName := Copy(FileName, 1, iPos -2);
if not cdsImages.Locate('FILENAME', sCDSFileName, []) then
begin
//* 01.12.12
if not bProcessingImages then
begin
bProcessingImages := True;
WriteLogEntry('Combining: Front and Back of Check Images into One File');
Application.ProcessMessages;
end;
lblProcessingFilename.Caption := sCDSFileName;
Application.ProcessMessages;
cdsImages.Append;
cdsImagesFILENAME.AsString := sCDSFileName;
cdsImages.Post;
//* Load the front of the check (in any format)
sFileName := sCDSFileName + 'F.*';
//* Import the files that we downloaded
if FindFirst(sTempDownloadDir + sFileName, faAnyFile, SRIndividual) = 0 then
begin
bFrontImageExists := True;
with ImageEnMView1.MIO do
begin
NativePixelFormat := False;
sOrigFrontImageFilename := SRIndividual.Name;
Try
LoadFromFile(sTempDownloadDir + SRIndividual.Name);
//* Rotate the image is necessary
RotateCheck(0);
Except
ShowMessage('Error Opening Image ' + SRIndividual.Name);
End;
end;
FindClose(SRIndividual);
end;
//* Load the back of the check (In any format)
sFileName := sCDSFileName + 'B.*';
//* Import the files that we downloaded
if FindFirst(sTempDownloadDir + sFileName, faAnyFile, SRIndividual) = 0 then
begin
bBackImageExists := True;
with ImageEnMView1.MIO do
begin
sOrigBackImageFilename := SRIndividual.Name;
NativePixelFormat := False;
Try
LoadFromFile(sTempDownloadDir + SRIndividual.Name);
//* Rotate the image is necessary
if bFrontImageExists then
RotateCheck(1)
else
RotateCheck(0);
Except
ShowMessage('Error Opening Image ' + SRIndividual.Name);
End;
end;
FindClose(SRIndividual);
end;
Application.ProcessMessages;
//* 06.02.12 to avoid an AV
if bFrontImageExists or bBackImageExists then
begin
//* Save to a multi-page tiff
ImageEnMView1.MIO.Params[0].TIFF_Compression := ioTIFF_G4FAX;
ImageEnMView1.MIO.Params[0].BitsPerSample := 1;
ImageEnMView1.MIO.Params[0].SamplesPerPixel := 1;
if bFrontImageExists and bBackImageExists then
begin
ImageEnMView1.MIO.Params[1].TIFF_Compression := ioTIFF_G4FAX;
ImageEnMView1.MIO.Params[1].BitsPerSample := 1;
ImageEnMView1.MIO.Params[1].SamplesPerPixel := 1;
end;
ImageEnMView1.MIO.SaveToFileTIFF(sReceiveDir + sCDSFileName + '.tif');
//* If the new image exists, then delete the old images
if FileExists(sTempDownloadDir + sOrigFrontImageFilename) then
DeleteFile(sTempDownloadDir + sOrigFrontImageFilename);
if FileExists(sTempDownloadDir + sOrigBackImageFilename) then
DeleteFile(sTempDownloadDir + sOrigBackImageFilename);
end;
end;
end;
end;
end;
end;