Step 4: Draw the Bitmap on the Client Area

 
Microsoft DirectShow 9.0

Step 4: Draw the Bitmap on the Client Area

The final step is to draw the bitmap onto the client area of the application window, using the Windows SetDIBitsToDevice function. This example simply paints the bitmap in the upper-left corner of the client area, without regard to the window size:

case WM_PAINT:
    {
        PAINTSTRUCT ps;
        HDC hdc = BeginPaint(hwnd, &ps);
        if (pbmi)
        {
            int result = SetDIBitsToDevice(hdc, 0, 0, 
                pbmi->biWidth,
                pbmi->biHeight,
                0, 0, 0,
                pbmi->biHeight,
                pBuffer,
                reinterpret_cast<BITMAPINFO*>(pbmi),
                DIB_RGB_COLORS);
        }
        EndPaint(hwnd, &ps);
    }
    break;