AutoTrim example for Visual J++

This example scans a document and trims the edges.

// Make sure display rectangles are reset when we acquire the image.
LEAD1.setAutoSetRects( true );

// Disable automatic repainting.
LEAD1.setAutoRepaint( false );

// Acquire the image, allowing for possible mistakes.
boolean bSavedSetting = LEAD1.getEnableMethodErrors();
LEAD1.setEnableMethodErrors( false );
short sRet = LEAD1.Load(“d:\temp\test.tif”, 0, 1, 1);
if( sRet != 0 )
{
   MessageBox.show( "image not loaded" );
   LEAD1.setEnableMethodErrors( bSavedSetting );
   return;
}
LEAD1.setEnableMethodErrors( bSavedSetting );

// Trim the edges of the acquired bitmap.
LEAD1.AutoTrim( (short) 64 );

// Use the whole window.
LEAD1.setLocation( 0, 0 );
LEAD1.setSize( getWidth(), getHeight() );

// Set up for good display of a typical scanned document.
LEAD1.setBitonalScaling( (short) LTOCXU.BitonalScalingConstants.BITONALSCALING_SCALETOGRAY );
LEAD1.setAutoScroll( true );
LEAD1.setDstWidth( LEAD1.getScaleWidth() ); // Use the full control width.
LEAD1.setDstClipWidth( LEAD1.getScaleWidth() );
int nCalcHeight = (int) ( ( LEAD1.getBitmapHeight() * LEAD1.getScaleWidth() ) / LEAD1.getBitmapWidth() );
LEAD1.setDstHeight( nCalcHeight );  // Use the proportional height.
LEAD1.setDstClipHeight( nCalcHeight );

// Enable automatic repainting.
LEAD1.setAutoRepaint( true );