LoadInfo... example for C++ 4.0 and later

Take the following steps to exercise the LoadInfo 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. Edit TUTORDLG.H and insert the following lines in the definition of CTutorDlg after DECLARE_MESSAGE_MAP():

// Declare variables for demonstrating raw FAX.
int MyInfoBits;
long MyInfoFlags;
int MyInfoFormat;
float MyInfoHeight;
long MyInfoOffset;
float MyInfoWidth;
int MyInfoXRes;
int MyInfoYRes;

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

void CTutorDlg::OnButton1()
{
  m_Lead1.SetScaleMode(3); // Pixels

  // Make the image look OK as a 1-bit image.
  m_Lead1.Size(m_Lead1.GetScaleWidth(), m_Lead1.GetScaleHeight(), RESIZE_RESAMPLE);
  m_Lead1.Halftone(HALFTONE_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 = m_Lead1.GetBitmapHeight();
  MyInfoOffset = 0;
  MyInfoWidth = m_Lead1.GetBitmapWidth();
  MyInfoXRes = m_Lead1.GetBitmapXRes();
  MyInfoYRes = m_Lead1.GetBitmapYRes();

  // Save the image as raw FAX; then load the saved file.
  // Format information will be supplied in the LoadInfo event.
  m_Lead1.Save("c:\\lead\\images\\tmp.tif", FILE_FAX_G3_2D, 1, 1, SAVE_OVERWRITE);
  m_Lead1.Load("c:\\lead\\images\\tmp.tif", 0, 0, 1);

  // Repaint the newly loaded image.
  m_Lead1.ForceRepaint();

}

4. Code the Lead1 control's LoadInfo event as follows:

void CTutorDlg::OnLoadInfoLead1()
{
   // Use the form-level variables to supply format information.
  m_Lead1.SetLoadInfoBits( MyInfoBits);
  m_Lead1.SetLoadInfoFlags( MyInfoFlags);
  m_Lead1.SetLoadInfoFormat( MyInfoFormat);
  m_Lead1.SetLoadInfoHeight( MyInfoHeight);
  m_Lead1.SetLoadInfoOffset( MyInfoOffset);
  m_Lead1.SetLoadInfoWidth( MyInfoWidth);
  m_Lead1.SetLoadInfoXRes( MyInfoXRes);
  m_Lead1.SetLoadInfoYRes( MyInfoYRes);
}

5. Run your program to test it.