Microsoft DirectX 8.1 (C++)

GetBitmapFormatSize

The GetBitmapFormatSize function calculates the size needed for a VIDEOINFO structure that can hold a specified BITMAPINFOHEADER structure.

Syntax

LONG GetBitmapFormatSize(
  const BITMAPINFOHEADER *pHeader
);

Parameters

pHeader

Pointer to a BITMAPINFOHEADER structure.

Return Value

Returns the size, in bytes.

Remarks

A BITMAPINFOHEADER structure might be followed by color masks or palette entries, so it can be difficult to determine the number of bytes required to construct a VIDEOINFO structure from an existing BITMAPINFOHEADER structure.

To copy a BITMAPINFOHEADER structure into a VIDEOINFO structure, use the HEADER macro, which calculates the correct offset.

Example Code

LONG size = GetBitmapFormatSize(&bmi);
VIDEOINFO *pVi = static_cast<VIDEOINFO*>(CoTaskMemAlloc(size));
CopyMemory(HEADER(pVi), &bmi, sizeof(BITMAPINFOHEADER));

Requirements

Header: Declared in Wxutil.h; include Streams.h.

Library: Use Strmbase.lib (retail builds) or Strmbasd.lib (debug builds).

See Also