Available in the LEADTOOLS Imaging toolkit. |
DrawText example for Visual J++
This example demonstrates most of the properties of a three-dimensional text object as it draws rotated text on the current bitmap.
LEAD1.setAutoRepaint( false );
// Load an image for the main control
LEAD1.Load( "c:\\lead\\images\\image1.cmp", (short) 0, (short) 0, (short) 1 );
// Load an image for the foreground of the text
LEAD2.Load( "c:\\lead\\images\\ulay1.bmp", (short) 0, (short) 0, (short) 1 );
// Text location
LEAD1.setTextTop( 50 );
LEAD1.setTextLeft( 50 );
LEAD1.setTextWidth( LEAD1.getDstWidth() - 50 );
LEAD1.setTextHeight( LEAD1.getDstHeight() - 50 );
// The foreground image needs to be the correct size.
LEAD2.Size( LEAD1.getTextWidth(), LEAD1.getTextHeight(), (short) 0 );
// Text alignment and angle
LEAD1.setTextAlign( (short)
LTOCXU.EfxTextAlignConstants.EFX_TEXTALIGN_HCENTER_VCENTER );
LEAD1.setTextAngle( (short) 450 ); // 45 degrees
// Text highlight color and style
LEAD1.setTextHiliteColor( new Color( 255, 255, 255 ) );
LEAD1.setTextStyle( (short) LTOCXU.EfxTextStyleConstants.EFX_TEXTSTYLE_DROPSHADOW );
// Text drop shadow
LEAD1.setShadowColor( new Color( 0, 0, 0 ) );
LEAD1.setShadowXDepth( 5 );
LEAD1.setShadowYDepth( 5 );
// Make the text a permanent part of the bitmap
LEAD1.setDrawPersistence( true );
// Draw the text
LEAD1.DrawText( "LEADTOOLS", LEAD2.getBitmap() );
LEAD1.ForceRepaint();