Available in the LEADTOOLS Imaging toolkit. |
Trim example for Visual J++
This example crops one-tenth from the bitmap and repaints the image.
int nNewLeft = (int) ( LEAD1.getBitmapWidth() * 0.1f );
int nNewTop = (int) ( LEAD1.getBitmapHeight() * 0.1f );
int nNewWidth = (int) ( LEAD1.getBitmapWidth() * 0.8f );
int nNewHeight = (int) ( LEAD1.getBitmapHeight() * 0.8f );
LEAD1.Trim( nNewLeft, nNewTop, nNewWidth, nNewHeight );
// Set variables for the position and size of the display rectangle.
int nViewWidth = (int) LEAD1.getScaleWidth();
int nViewHeight = (int) LEAD1.getScaleHeight();
// Set the image display size to match the LEAD control
LEAD1.SetDstRect( 0, 0, nViewWidth, nViewHeight );
LEAD1.SetDstClipRect( 0, 0, nViewWidth, nViewHeight );
LEAD1.ForceRepaint();