ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Sudden AV due to MIO.Params[0] is now nil

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
stwizard Posted - Jan 26 2015 : 09:55:34
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;
3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Feb 09 2016 : 12:49:44
Hi Raghu

Can you send us your image and the steps you are taking so I can ensure ImageEn is handling the failure correctly.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
raghutumma Posted - Feb 09 2016 : 02:03:52
Dear stwizard,

were you able to fix this?. If yes, what was the correct code.

Regards,
Raghu
stwizard Posted - Jan 26 2015 : 10:42:17
I think I may have figured out what was going on. It appears that some of the images in gif format where bad and because of this I think this was causing the Param[0] to be nil. I'll report back shortly.

Update: It was due to bad gif images.