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.


#include "l_bitmap.h"

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


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.


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


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


Win32, x64.

See Also




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("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); 
   hbmMem = (HBITMAP)SelectObject(hdcSrc, hbmMem); 
   if (nBitsPerPixel <= 8) 
      hPaintPal = L_CreatePaintPalette(hdcDest, &Bitmap); 
      hSavedPalette = SelectPalette(hdcDest, hPaintPal, FALSE); 
      // Realize our palette 
   // 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); 
   // Release the device context 
   ReleaseDC(hWnd, hdcDest); 
   return SUCCESS; 

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

LEADTOOLS Raster Imaging C API Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.