• Api Documentation
  • Source Code
Search Results for

    Show / Hide Table of Contents
    • JeremyAnsel.DirectX.MediaFoundation
      • MF2DBuffer
      • MFAttributes
      • MFDXGIDeviceManager
      • MFFactory
      • MFHelpers
      • MFMediaBuffer
      • MFMediaFormatGuids
      • MFMediaFormatGuids.Audio
      • MFMediaFormatGuids.Image
      • MFMediaFormatGuids.Video
      • MFMediaType
      • MFMediaTypeGuids
      • MFMediaTypeMajorGuids
      • MFReadWriteGuids
      • MFSample
      • MFSinkWriter
      • MFSinkWriterGuids
      • MFSourceReader
      • MFSourceReaderControlFlags
      • MFSourceReaderFlags
      • MFSourceReaderGuids
      • MFVideoInterlaceMode

    Class MF2DBuffer

    The IMF2DBuffer interface is supported by a media buffer whose multimedia data represents a 2D media type e.g. video. For these media types it is important to know the "pitch" of the buffer which indicates the number of bytes required to go from scanline to scanline. The IMF2DBuffer interface is obtained from a buffer by calling QueryInterface(). For each 2D media type a contiguous standard representation is defined which is designed to be compatible with the standard layout of a DirectX surface when represented by system memory. In this representation the surface pitch is always positive and equal to the number of bytes taken up by a single row of pixels padded out to a 4-byte boundary.

    Applications may still access 2D buffers using IMFBuffer::Lock(). In that case the data in the buffer will always be in the standard contiguous format for the format of data represented by the buffer. An internal copy may be required on IMFBuffer::Lock() and IMFBuffer::Unlock() to achieve this. The copy will not occur if the buffer is already in the correct format. When a copy occurs an event will be generated to aid debugging performance issues resulting from the copy. Components that process 2D data should aim to use the IMF2DBuffer interface to access sample data.

    Inheritance
    object
    DXComObject
    MF2DBuffer
    Implements
    IDisposable
    Inherited Members
    DXComObject.Dispose()
    DXComObject.AddRef()
    DXComObject.Release()
    DXComObject.QueryInterface(in Guid)
    DXComObject.Handle
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: JeremyAnsel.DirectX.MediaFoundation
    Assembly: JeremyAnsel.DirectX.MediaFoundation.dll
    Syntax
    [SecurityCritical]
    public class MF2DBuffer : DXComObject, IDisposable

    Constructors

    | Edit this page View Source

    MF2DBuffer(nint)

    Initializes a new instance of the MF2DBuffer class.

    Declaration
    public MF2DBuffer(nint comPtr)
    Parameters
    Type Name Description
    nint comPtr

    Fields

    | Edit this page View Source

    MF2DBufferGuid

    The interface GUID.

    Declaration
    public static readonly Guid MF2DBufferGuid
    Field Value
    Type Description
    Guid

    Methods

    | Edit this page View Source

    ContiguousCopyFrom(nint, uint)

    The ContiguousCopyFrom method copies the contents of the caller's buffer which is in contiguous format into the buffer - correcting for the buffer's pitch as necessary.

    Declaration
    public void ContiguousCopyFrom(nint pbSrcBuffer, uint cbSrcBuffer)
    Parameters
    Type Name Description
    nint pbSrcBuffer

    Pointer to where to copy the contiguous from.

    uint cbSrcBuffer

    Number of bytes to copy. This must match the value returned by GetContiguousLength. If it doesn't this method returns E_INVALIDARG.

    | Edit this page View Source

    ContiguousCopyTo(nint, uint)

    The ContiguousCopyTo method copies the contents of the buffer into the caller's buffer in contiguous format.

    Declaration
    public void ContiguousCopyTo(nint pbDestBuffer, uint cbDestBuffer)
    Parameters
    Type Name Description
    nint pbDestBuffer

    Pointer to where to store the contiguous data to.

    uint cbDestBuffer

    Number of bytes to copy. This must match the value returned by GetContiguousLength. If it doesn't this method returns E_INVALIDARG.

    | Edit this page View Source

    GetContiguousLength()

    The GetContiguousLength method returns the number of bytes required store the buffer contents in contiguous format.

    Declaration
    public uint GetContiguousLength()
    Returns
    Type Description
    uint
    | Edit this page View Source

    GetScanline0AndPitch(out nint, out uint)

    The GetScanline0AndPitch returns a pointer to the start of the first line and the pitch of the buffer. The memory pointer and pitch value are only valid while there is at least one outstanding Lock call with an unmactched Unlock call.

    Declaration
    public void GetScanline0AndPitch(out nint pbScanline0, out uint plPitch)
    Parameters
    Type Name Description
    nint pbScanline0

    Pointer to a byte ponter where the pointer to the first byte of the top row of the buffer will be stored

    uint plPitch

    Pointer to a count of bytes where the pitch of the buffer will be stored. This value can be added to a pointer to the start of a given row of the buffer to get the pointer to the start of the next row of the buffer.

    | Edit this page View Source

    IsContiguousFormat()

    The IsContignousFormat method returns a BOOL value which is TRUE if the buffer is in contiguous format and FALSE if it is not in contiguous format.

    Declaration
    public bool IsContiguousFormat()
    Returns
    Type Description
    bool
    | Edit this page View Source

    Lock2D(out nint, out uint)

    The Lock2D method ensures the buffer memory is accessible in the correct format and returns a pointer to the start of the first line and the pitch of the buffer. Each call to Lock2D must be matched by a corresponding call to Unlock2D. The memory pointer and pitch value are only valid while there is at least one outstanding Lock2D call with an unmactched Unlock2D call.

    Declaration
    public void Lock2D(out nint ppbScanline0, out uint plPitch)
    Parameters
    Type Name Description
    nint ppbScanline0

    Pointer to a byte ponter where the pointer to the first byte of the top row of the buffer will be stored

    uint plPitch

    Pointer to a count of bytes where the pitch of the buffer will be stored. This value can be added to a pointer to the start of a given row of the buffer to get the pointer to the start of the next row of the buffer.

    | Edit this page View Source

    Unlock2D()

    The Unlock2D method unlocks the buffer. Each call to Lock2D must be matched by a call to Unlock2D. When there are no more outstanding Unlocks all existing pointers to the buffer and pitch values should be considered invalid.

    Declaration
    public void Unlock2D()

    Implements

    IDisposable
    • Edit this page
    • View Source
    In this article
    Back to top Copyright (c) 2026 Jérémy Ansel