OnLoadInfo example for Delphi

Take the following steps to exercise the OnLoadInfo event and LoadInfo... properties. The example creates a raw FAX file, then loads the file it just created. (Getting format information from an unfamiliar file is beyond the scope of this example.)

1.

Start with the project that you created in Loading and Displaying an Image.

2.

Add the following declarations to the private section of the Unit1 file. In online help, you can copy the block of code and paste it into your application.

{Declare variables for demonstrating raw FAX.}
MyInfoBits: Integer;
MyInfoFlags: Integer;
MyInfoFormat: Integer;
MyInfoHeight: Integer;
MyInfoOffset: Longint;
MyInfoWidth: Integer;
MyInfoXRes: Integer;
MyInfoYRes: Integer;

3.

image\btndbtn.gif Add a CommandButton control and code its click procedure as follows:

procedure TForm1.Button1Click(Sender: TObject);
begin
    {Make the image look OK as a 1-bit image.}
    Lead1.Size(Lead1.Width, Lead1.Height, SIZE_RESAMPLE);
    Lead1.Halftone(HT_VIEW, 45);

    {Set the form-level variables to the values we will use when loading.}
    MyInfoBits := 1;
    MyInfoFlags := LOADINFO_TOPLEFT;
    MyInfoFormat := FILE_FAX_G3_2D;
    MyInfoHeight := Lead1.BitmapHeight;
    MyInfoOffset := 0;
    MyInfoWidth := Lead1.BitmapWidth;
    MyInfoXRes := Lead1.BitmapXRes;
    MyInfoYRes := Lead1.BitmapYRes;

    {Save the image as raw FAX; then load the saved file.}
    {Format information will be supplied in the OnLoadInfo event.}
    Lead1.Save('C:\lead\IMAGES\TMP.TIF', FILE_FAX_G3_2D, 1, 1, SAVE_OVERWRITE);
    Lead1.Load('C:\lead\IMAGES\TMP.TIF', 0, 0, 1);

    {Repaint the newly loaded image.}
    Lead1.ForceRepaint;

End;

4.

Code the Lead1 control's OnLoadInfo event as follows:

procedure TForm1.Lead1LoadInfo(Sender: TObject);
begin
    {Use the form-level variables to supply format information.}
    Lead1.LoadInfoBits := MyInfoBits;
    Lead1.LoadInfoFlags := MyInfoFlags;
    Lead1.LoadInfoFormat := MyInfoFormat;
    Lead1.LoadInfoHeight := MyInfoHeight;
    Lead1.LoadInfoOffset := MyInfoOffset;
    Lead1.LoadInfoWidth := MyInfoWidth;
    Lead1.LoadInfoXRes := MyInfoXRes;
    Lead1.LoadInfoYRes := MyInfoYRes;
End;

5.

Run your program to test it.