Microsoft DirectX 9.0 |
When graphics hardware or GDI allocates a memory buffer for bitmaps, it often pads the rows with extra bytes in order to align them on some boundary. The width of the image, in bytes, plus the width of the extra padding, is called the stride. Another way to think of it is that stride gives the number of bytes it takes to advance from the beginning of one row in an image to the beginning of the next row.
For RGB DIBs, the stride is always aligned at least to a DWORD boundary. The same is true for YUV formats where the bitdepth is an even power of 2. Decoders and video sources should propose a format where the biWidth member of the BITMAPINFOHEADER is the width of the image. The video renderer may modify the format so that biWidth equals the stride of the surface, and the rcTarget member of the VIDEOINFOHEADER or VIDEOINFOHEADER2 structure specifies the image width. The video renderer proposes the modified format by calling IPin::QueryAccept on the output pin, and then attaching the new format to the next media sample. For details, see Dynamic Format Changes. If the video renderer does not change the format to specify the stride, then you should round the biWidth value up to the nearest DWORD boundary (except for non-power-of-2 YUV formats).
Never assume that stride is equal to the image width, even with 32-bit pixel formats, because many graphics cards require an alignment that is 64 bits or greater.