LoadInfo... example for Visual J++

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. Add the following form-level variables to the private section of your main form:

// Declare variables for demonstrating raw FAX.
private int m_nMyInfoBits;
private int m_nMyInfoFlags;
private int m_nMyInfoFormat;
private int m_nMyInfoHeight;
private int m_nMyInfoOffset;
private int m_nMyInfoWidth;
private int m_nMyInfoXRes;
private int m_nMyInfoYRes;

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

private void button1_click(Object source, Event e)
{
   // Make the image look OK as a 1-bit image.
   LEAD1.Size( LEAD1.getScaleWidth(), LEAD1.getScaleHeight(), (short) LTOCXU.ResizeConstants.RESIZE_RESAMPLE );
   LEAD1.Halftone( (short) LTOCXU.HalftoneConstants.HALFTONE_VIEW, 45 );

   // Set the form-level variables to the values we will use when loading.
   m_nMyInfoBits = 1;
   m_nMyInfoFlags = LTOCXU.LoadInfoFlagConstants.LOADINFO_TOPLEFT;
   m_nMyInfoFormat = LTOCXU.FileConstants.FILE_FAX_G3_2D;
   m_nMyInfoHeight = (int) LEAD1.getBitmapHeight();
   m_nMyInfoOffset = 0;
   m_nMyInfoWidth = (int) LEAD1.getBitmapWidth();
   m_nMyInfoXRes = LEAD1.getBitmapXRes();
   m_nMyInfoYRes = LEAD1.getBitmapYRes();

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

   // Repaint the newly loaded image.
   LEAD1.ForceRepaint();
}

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

private void LEAD1_loadInfo(Object source, Event e)
{
   // Use the form-level variables to supply format information.
   LEAD1.setLoadInfoBits( (short) m_nMyInfoBits );
   LEAD1.setLoadInfoFlags( m_nMyInfoFlags );
   LEAD1.setLoadInfoFormat( (short) m_nMyInfoFormat );
   LEAD1.setLoadInfoHeight( m_nMyInfoHeight );
   LEAD1.setLoadInfoOffset( m_nMyInfoOffset );
   LEAD1.setLoadInfoWidth( m_nMyInfoWidth );
   LEAD1.setLoadInfoXRes( (short) m_nMyInfoXRes );
   LEAD1.setLoadInfoYRes( (short) m_nMyInfoYRes );
}

5. Run your program to test it.