Currently viewing: GipsySoft » Front Page» Articles

DrawTiledBitmap

Tiles a bitmap within the region specified (x, y, cx, cy). It will optionally use the clipping region for the DC provided. This can substantially reduce the number of images drawn, especially when another window passes over.

void DrawTiledBitmap( int x, int y, int cx, int cy, HDC hdc, HBITMAP hbm, bool bUseClipping );

Return value

No return value

Example
This what a typical usage might look like in a WM_PAINT message handler

case WM_PAINT:
  {
    PAINTSTRUCT ps;
    BeginPaint( hwnd, &ps );
    HBITMAP hbm = LoadBitmap( GetModuleHandle( NULL )
        , MAKEINTRESOURCE( IDB_TEST ) );
    RECT rc;
    GetClientRect( hwnd, &rc );
    const int nWidth = rc.right - rc.left;
    const int nHeight = rc.bottom - rc.top;

    DrawTiledBitmap( 0, 0, nWidth, nHeight, ps.hdc, hbm, true );

    DeleteObject( hbm );

    EndPaint( hwnd, &ps );
  }
  break;

 

Click to view the source code

See also DrawBitmap DrawBitmapStretched