L_EfxTileRect

#include "l_bitmap.h"

L_LTEFX_API L_INT L_EfxTileRect(hdcDest, prcDest, hdcSrc, prcSrc)

Performs a bit-block transfer of the source rectangle of pixels from the specified source device context into a destination device context, while tiling the source to fit the destination.

Parameters

HDC hdcDest

Handle to the target device context.

RECT *prcDest

Pointer to the destination rectangle.

HDC hdcSrc

Handle to the source device context.

RECT *prcSrc

Pointer to the source rectangle.

Returns

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

Comments

Use this function as a replacement for the Windows BitBlt C API function when you want a special painting effect.

If the source rectangle is smaller than the destination rectangle, then the source rectangle will be duplicated (tiled) as many times as necessary to fit the destination rectangle.

For general information, refer to Implementing Special Effects.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This function shows how to use L_EfxTileRect.

L_INT EfxTileRectExample(HWND hWnd) 
{ 
  L_INT nRet; 
  HDC          hdcDest;                /* Device context for the current window */ 
  HDC          hdcSrc;                 /* Device context for the source image */ 
  BITMAPHANDLE Bitmap;                 /* image that will be blt */ 
  HBITMAP      hbmMem;                 /* image that will be blt */ 
  HPALETTE     hSavedPalette = NULL;   /* Temporary copy of the current system palette */ 
  HPALETTE     hPaintPal = NULL;       /* The palette that we will use to paint */ 
  L_INT        nBitsPerPixel; 
  L_RECT       rcDst; 
  L_RECT       rcSrc; 
 
  /* Get the device context */ 
  hdcDest = GetDC (hWnd); 
  /* Check the device to see if we need a palette */ 
  nBitsPerPixel = GetDeviceCaps( hdcDest, BITSPIXEL ) * GetDeviceCaps ( hdcDest, PLANES ); 
  /* Load an image to BLT */ 
  /* Load the image as screen bit-depth */ 
  nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &Bitmap, sizeof(BITMAPHANDLE), (nBitsPerPixel <= 8) ? nBitsPerPixel : 24, ORDER_BGR, NULL, NULL ); 
  if(nRet != SUCCESS) 
     return nRet; 
  /* Create the source DC */ 
  hdcSrc = CreateCompatibleDC(hdcDest); 
  /* Convert the image to DDB and select it into the source dc */ 
  hbmMem = L_ConvertToDDB ( hdcDest, &Bitmap ); 
  L_FreeBitmap(&Bitmap); 
  hbmMem = (HBITMAP)SelectObject(hdcSrc, hbmMem); 
  if ( nBitsPerPixel <=8 ) 
  { 
    hPaintPal = L_CreatePaintPalette( hdcDest, &Bitmap ); 
    hSavedPalette = SelectPalette (hdcDest, hPaintPal, FALSE); 
    /* Realize our palette */ 
    RealizePalette (hdcDest);  
  } 
  /* tile the image using L_EfxTileRect */ 
  GetClientRect(hWnd, &rcDst); 
  SetRect(&rcSrc, 0, 0, 100, 100); 
  nRet = L_EfxTileRect(hdcDest, &rcDst, hdcSrc, &rcSrc); 
  if(nRet != SUCCESS) 
     return nRet; 
 
  /* Restore the old palette */ 
  if  ( hPaintPal ) 
  { 
    SelectPalette (hdcDest, hSavedPalette, FALSE); 
    DeleteObject (hPaintPal); 
  } 
  /* Release the device context */ 
  ReleaseDC ( hWnd, hdcDest ); 
  DeleteDC(hdcSrc);     
  DeleteObject(hbmMem); 
  return SUCCESS; 
} 

Help Version 21.0.2021.7.5
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.