L_EfxGradientFillRect

#include "l_bitmap.h"

L_LTEFX_API L_INT L_EfxGradientFillRect(hDC, pRect, uStyle, crStart, crEnd, uSteps)

Draws a rectangle into the target device context, and then fills the rectangle with a gradient from the specified starting color to the specified ending color.

Parameters

HDC hDC

Handle to the target device context.

RECT * pRect

Pointer to the display destination rectangle.

L_UINT uStyle

Gradient style. For valid values, refer to Effect Gradient Styles.

COLORREF crStart

COLORREF value that specifies the starting color.

COLORREF crEnd

COLORREF value that specifies the ending color.

L_UINT uSteps

Number of gradient color steps. Valid values are 2 to 256.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This example shows the minimum requirements for using the L_EfxGradientFillRect
function to draw and fill a rectangle with a color gradient.

L_INT EfxGradientFillRectExample(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; 
 
  /* Get the device context */ 
  hdc = GetDC (hWnd); 
  /* 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 gradient filled rectangle */ 
  nRet = L_EfxGradientFillRect(hdc,                       /* device context */ 
                        pDest,                     /* destination rectangle */ 
                        EFX_GRADIENT_ELLIPSE_TO_C, /* out to center */ 
                        RGB ( 255,0,0 ),           /* starting color, red */ 
                        RGB ( 0,0,255 ),           /* ending color, blue */ 
                        12 );                      /* gradient color steps */ 
  if(nRet != SUCCESS) 
     return nRet; 
 
  /* Restore the old palette */ 
  if  ( hOurPalette ) 
    SelectPalette (hdc, hSavedPalette, FALSE); 
  /* Release the device context */ 
  ReleaseDC(hWnd, hdc); 
   return SUCCESS; 
} 

Help Version 21.0.2023.2.15
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.