L_EfxDrawRotated3dText

#include "l_bitmap.h"

L_LTEFX_API L_INT L_EfxDrawRotated3dText(hDC, pszText, pRect, nAngle, uFlags, nXDepth, nYDepth, crText, crShadow, crHilite, hFont, hdcFore)

HDC hDC;

/* handle to the target device context */

L_TCHAR * pszText;

/* text string */

RECT *pRect;

/* pointer to the display rectangle */

L_INT nAngle;

/* Text angle */

L_UINT uFlags;

/* text style */

L_INT nXDepth;

/* horizontal shadow position */

L_INT nYDepth;

/* vertical shadow position */

COLORREF crText;

/* text color */

COLORREF crShadow;

/* shadow color */

COLORREF crHilite;

/* border color */

HFONT hFont;

/* handle to the selected font */

HDC hdcFore;

/* handle to the source device context for foreground */

Draws three-dimensional text which is rotated by the amount specified into the target device context using the specified font, color, and style.

Parameter

Description

hDC

Handle to the target device context.

pszText

Text string.

pRect

Pointer to the display destination rectangle.

nAngle

Text angle, in tenths of degrees.

uFlags

Text style. Use this parameter to control the style and justification of the three-dimensional text. For valid values, refer to Effect Text Style Flags and Effect Text Alignment Flags.

nXDepth

Horizontal shadow position.

nYDepth

Vertical shadow position.

crText

COLORREF value that specifies the text color.

crShadow

COLORREF value that specifies the shadow color.

crHilite

COLORREF value that specifies the border color.

hFont

Handle to the selected font. The font must be TrueType in order to rotate.

hdcFore

Handle to the source device context for the foreground. Use this parameter to place an image (such as a gradient) on the surface of the three-dimensional text. Use NULL to paint the color specified in crText.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The font must be TrueType in order to rotate. The rotation point will be calculated from (X, 0).

Drop shadows are available only for the following uFlags values:

EFX_TEXT_DROPSHADOW
EFX_TEXT_BLOCKSHADOW
EFX_TEXT_OUTLINEBLOCK

The crShadow color is used for three-dimensional effects for the following uFlags values:

EFX_TEXT_INSETHEAVY
EFX_TEXT_INSETEXTRAHEAVY
EFX_TEXT_RAISEDHEAVY
EFX_TEXT_RAISEDEXTRAHEAVY

The crHilite color is used only for the following uFlags values:

EFX_TEXT_INSETLIGHT
EFX_TEXT_INSETEXTRALIGHT
EFX_TEXT_INSETHEAVY
EFX_TEXT_INSETEXTRAHEAVY
EFX_TEXT_RAISEDLIGHT
EFX_TEXT_RAISEDEXTRALIGHT
EFX_TEXT_RAISEDHEAVY
EFX_TEXT_RAISEDEXTRAHEAVY
EFX_TEXT_OUTLINEBLOCK

For general information, refer to Implementing Special Effects.

Required DLLs and Libraries

LTEFX

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 2000 / XP/Vista.

See Also

Functions:

L_EfxDraw3dShape, L_EfxDraw3dText, L_EfxDrawFrame, L_EfxEffectBlt, L_EfxGradientFillRect, L_EfxPaintBitmap, L_EfxPaintTransition, L_EfxPatternFillRect

Topics:

Implementing Special Effects

 

Using Color Values in LEADTOOLS

Example

This example shows the minimum requirements for using L_EfxDrawRotated3dText.

 L_INT EfxDrawRotated3dTextExample(HWND   hWnd, RECT*  pDest)
{
  L_INT nRet;
  HDC       hdc;                    /* Device context for the current window */
  HPALETTE  hSavedPalette = NULL;   /* Temporary copy of the current system palette */
  HPALETTE  hOurPalette = NULL;     /* The palette that we will use to paint */
  L_INT     nBitsPerPixel;
  HFONT     hFont;                  /* Font to use for the text, must be TrueType */
  HDC       hdcMem;                 /* HDC for foreground image */
  HBITMAP   hbmMem;                 /* Bitmap for foreground image */
  RECT      rcbm;

  /* Get the device context */
  hdc = GetDC (hWnd);
  /* Create the gradient for the foreground of the 3D text */  
  rcbm.top     = pDest->top;
  rcbm.left    = pDest->left;
  rcbm.bottom  = pDest->bottom;
  rcbm.right   = pDest->right;

  OffsetRect(&rcbm, -pDest->left, -pDest->top);
  hdcMem = CreateCompatibleDC(hdc);
  hbmMem = CreateCompatibleBitmap(hdc, rcbm.right, rcbm.bottom);
  hbmMem = (HBITMAP)SelectObject(hdcMem, hbmMem);
  /* Place a gradient in the foreground of the 3D text */
  nRet = L_EfxGradientFillRect(hdcMem,
                        &rcbm,
                        EFX_GRADIENT_LINE_L_TO_R,
                        RGB(255, 0, 0),
                        RGB(0, 0, 255),
                        16 );
  if(nRet != SUCCESS)
     return nRet;

  /* Create the font */
  hFont = CreateFont(-MulDiv(32, GetDeviceCaps(hdc, LOGPIXELSY), 72),
                     0, 0, 0,
                     FW_BOLD, FALSE, FALSE, FALSE,
                     DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
                     CLIP_DEFAULT_PRECIS,
                     DEFAULT_QUALITY,
                     DEFAULT_PITCH,
                     TEXT("Arial"));

  /* Check the device to see if we need a palette */
  nBitsPerPixel = GetDeviceCaps( hdc, BITSPIXEL ) * GetDeviceCaps ( hdc, PLANES );
  if ( nBitsPerPixel <=8 )
  {
    hOurPalette = (HPALETTE)GetStockObject (DEFAULT_PALETTE);
    hSavedPalette = SelectPalette (hdc, hOurPalette, FALSE);
    /* Realize our palette */
    RealizePalette (hdc); 
  }
  /* Draw the Rotated  3D text */
  nRet = L_EfxDrawRotated3dText(hdc,                   /* device context */
                         TEXT("Rotated 3D Text - LEADTOOLS"),
                         pDest,                 /* destination rectangle */
                         300,                   /* rotate 30 degrees*/
                         /* style flags for 3D text */
                         EFX_TEXT_DROPSHADOW | EFX_TEXT_HCENTER | EFX_TEXT_VCENTER,
                         2,                     /* horizontal  shadow position */
                         2,                     /* vertical shadow position */
                         RGB ( 0,0,255 ),       /* text color, blue */
                         RGB ( 0,0,0 ),         /* shadow color, black */
                         RGB ( 255,255,255 ),   /* border color, white */
                         hFont,
                         hdcMem );              /* use this to put an image in the font */
  if(nRet != SUCCESS)
     return nRet;

  /* Restore the old palette */
  if  ( hOurPalette )
    SelectPalette (hdc, hSavedPalette, FALSE);
  /* Release the device context */
  ReleaseDC(hWnd, hdc);
  DeleteObject (hFont);
  DeleteObject(SelectObject(hdcMem, hbmMem));
  DeleteDC(hdcMem); 
   return SUCCESS;
}