IMF2DBuffer::Lock2D method

In this article

Syntax

Parameters

Receives the surface stride, in bytes. The stride might be negative, indicating that the image is oriented from the bottom up in memory.

Return Value

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code

Description

S_OK

The method succeeded.

D3DERR_INVALIDCALL

Cannot lock the Direct3D surface.

MF_E_INVALIDREQUEST

The buffer cannot be locked at this time.

Remarks

If p is a pointer to the first byte in a row of pixels, p + (*plPitch) points to the first byte in the next row of pixels. A buffer might contain padding after each row of pixels, so the stride might be wider than the width of the image in bytes. Do not access the memory that is reserved for padding bytes, because it might not be read-accessible or write-accessible. For more information, see Image Stride.

The pointer returned in pbScanline0 remains valid as long as the caller holds the lock. When you are done accessing the memory, call IMF2DBuffer::Unlock2D to unlock the buffer. You must call Unlock2D once for each call to Lock2D. After you unlock the buffer, the pointer returned in pbScanline0 is no longer valid and should not be used. Generally, it is best to call Lock2D only when you need to access the buffer memory, and not earlier.

See Also

The feedback system for this content will be changing soon. Old comments will not be carried over. If content within a comment thread is important to you, please save a copy. For more information on the upcoming change, we invite you to read our blog post.