Microsoft DirectX 9.0


The WriteBitmapBits method retrieves a video frame at the specified media time and writes it to a file.  The video frame is always in 24-bit RGB format.


HRESULT WriteBitmapBits(
    double StreamTime, 
    long Width, 
    long Height, 
    BSTR Filename 



Time at which to retrieve the video frame.


Width of the image, in pixels.


Height of the image, in pixels.


Path of the file in which to save the bitmap. If the file already exists, this method overwrites it.

Return Value

Returns S_OK it successful. Otherwise, returns an HRESULT value that indicates the cause of the error. Possible error codes include the following:

Value Description
E_NOINTERFACE Could not add the Sample Grabber filter to the graph.
E_FAIL Failure.
E_OUTOFMEMORY Insufficient memory.
E_UNEXPECTED Unexpected error.
STG_E_ACCESSDENIED Cannot overwrite file.
VFW_E_INVALIDMEDIATYPE Invalid media type.


Before calling this method, set the file name and stream by calling IMediaDet::put_Filename and IMediaDet::put_CurrentStream.

This method puts the media detector into bitmap grab mode. Once this method has been called, the various stream information methods in IMediaDet do not work, unless you create a new instance of the media detector.


Header: Include Qedit.h. This header file is not compatible with Microsoft® Direct3D® headers later than version 7.

Library: Use strmiids.lib.

See Also