This class initializes itself with a display format so that other objects can query or reset the display type. It also provides member functions to check display formats and accept only those video formats that can be efficiently rendered by using GDI calls.
Protected Data Members
Name | Description |
m_Display | VIDEOINFOHEADER structure corresponding to the current device display type. |
Member Functions
Name | Description |
CheckBitFields | Checks that the bit fields on a VIDEOINFOHEADER structure are correct. |
CheckHeaderValidity | Determines if a BITMAPINFOHEADER structure is valid. |
CheckMediaType | Determines if the filter can support the media type proposed by the output pin. |
CheckPaletteHeader | Determines if the palette on a VIDEOINFOHEADER structure is correct. |
CheckVideoType | Compares a video type to determine if it is compatible with the current display mode. |
CImageDisplay | Constructs a CImageDisplay object. |
CountPrefixBits | Counts the number of prefix bits. |
CountSetBits | Counts the total number of bits set in a field. |
GetBitMasks | Retrieves a set of color element bitmasks for the supplied VIDEOINFOHEADER structure. |
GetColourMask | Retrieves a set of individual color element masks. |
GetDisplayDepth | Retrieves the bit depth of the current display mode. |
GetDisplayFormat | Retrieves a VIDEOINFOHEADER structure representing the current display mode. |
IsPalettized | Determines if the display uses a palette. |
RefreshDisplayType | Updates the CImageDisplay object with the current display type. |
UpdateFormat | Updates the VIDEOINFOHEADER structure to remove implicit assumptions. |
Checks that the bit fields in the VIDEOINFOHEADER structure are correct.
BOOL CheckBitFields(
const VIDEOINFO *pInput
);
Returns one of the following values.
Value | Meaning |
TRUE | Bit fields are correct. |
FALSE | Bit fields contain an error. |
The assumption throughout the object is that any bitmasks are allowed no more than 8 bits to store a color component. This member function checks that the bit count assumption is enforced, and also ensures that all the bits set are contiguous.
This is a protected member function.
Determines if a BITMAPINFOHEADER structure is valid.
BOOL CheckHeaderValidity(
const VIDEOINFO *pInput
);
Returns one of the following values.
Value | Meaning |
TRUE | Format is valid. |
FALSE | Format contains an error. |
The BITMAPINFOHEADER structure might be rejected for a number of reasons. These might include a number-of-planes entry greater or less than one, the size of the structure not being equal to the size of BITMAPINFOHEADER, or, perhaps, being asked to validate a YUV format (this member function only validates RGB formats; it will always return FALSE for YUV types).
Determines if the filter can support the media type proposed by the output pin.
HRESULT CheckMediaType(
const CMediaType *pmtIn
);
Returns an HRESULT value.
This helper member function can be used to validate a video media type. It examines the major and minor type GUIDs and verifies that the format GUID defines a VIDEOINFOHEADER structure.
Determines if the palette on a VIDEOINFOHEADER structure is correct.
BOOL CheckPaletteHeader(
const VIDEOINFO *pInput
);
Returns one of the following values.
Value | Meaning |
TRUE | Palette is correct. |
FALSE | No valid palette. |
This member function returns FALSE if the format specifies that no palette is available (it might be a true-color format). It also returns FALSE if the number of palette colors used (or those that are important) exceeds the number specified for the video format.
Compares a video type to determine if it is compatible with the current display mode.
HRESULT CheckVideoType(
const VIDEOINFO *pInput
);
Returns an HRESULT value.
Many video rendering filters want a function to determine if proposed formats are okay. This member function checks the VIDEOINFOHEADER structure passed as a media type and returns NOERROR if the media type is valid; otherwise, it returns E_INVALIDARG434. Note, however, that only formats that can be easily displayed on the current display device are accepted; so, for example, a 16-bit device will not accept 24-bit images. Because most displays draw 8-bit palettized images efficiently, this format is always accepted unless the display is 16-color VGA.
Constructs a CImageDisplay object.
CImageDisplay( );
No return value.
The CImageDisplay class helps renderers that want to determine the format of the current display mode. This member function retrieves the display mode and creates a VIDEOINFOHEADER structure that represents its format. The class supplies that format for clients through member functions such as IsPalettized and GetDisplayFormat. If a client detects the display format has changed (perhaps it receives a WM_DISPLAYCHANGED message), it should call RefreshDisplayType.
Helper member function to count the number of prefix bits.
DWORD CountPrefixBits(
const DWORD Field
);
No return value.
Given a bitmask, this member function counts the number of zero bits up to the least significant set bit. So, for a binary number 00000100, the member function returns 2 (decimal). The member function does, however, work on DWORD values, so it counts from the least significant bit up through the DWORD to the last bit (0x80000000). If no bits are found, this will return the (impossible) value 32 (decimal).
This is a protected member function.
Counts the number of bit sets in the Field parameter.
DWORD CountSetBits(
const DWORD Field
);
Returns the number of bit sets.
This is a protected member function.
Retrieves a set of color element bitmasks for the supplied VIDEOINFOHEADER structure.
const DWORD *GetBitMasks(
const VIDEOINFO *pVideoInfo
);
No return value.
This member function should be called only with RGB formats. If the RGB format has a bit depth of 16/32 bits per pixel, it will return the bitmasks for the individual red, green, and blue color elements (for example, RGB565 is 0xF800, 0x07E0, and 0x001F). For RGB24, this will return 0xFF0000, 0xFF00, and 0xFF. For palettized formats, this will return all zeros.
Retrieves a set of individual color element masks.
BOOL GetColourMask(
DWORD *pMaskRed,
DWORD *pMaskGreen,
DWORD *pMaskBlue
);
Returns one of the following values.
Value | Meaning |
TRUE | Masks were filled out correctly. |
FALSE | No masks were available for the display. |
Given a video format described by a VIDEOINFOHEADER structure, this member function returns the mask that is used to obtain the range of acceptable colors for this type (for example, the mask for a 24-bit true color format is 0xFF in all cases). A 16-bit 5:6:5 display format uses 0xF8, 0xFC, and 0xF8. Therefore, given any RGB triplets, this member function can find one that is compatible with the display format by using a bitwise-AND operation.
Retrieves the bit depth of the current display mode.
WORD GetDisplayDepth( );
Returns the number of bits per pixel used on the display.
Retrieves a VIDEOINFOHEADER structure representing the current display mode.
const VIDEOINFO *GetDisplayFormat( );
Returns a VIDEOINFOHEADER structure representing the display format.
Determines if the display uses a palette.
BOOL IsPalettized( );
Returns TRUE if the display uses a palette; otherwise, returns FALSE.
Updates the CImageDisplay object with the current display type.
HRESULT RefreshDisplayType(
LPSTR szDeviceName
);
Returns an HRESULT value.
This member function should be called when a WM_DISPLAYCHANGED message is received.
Updates the VIDEOINFOHEADER structure to remove implicit assumptions.
HRESULT UpdateFormat(
VIDEOINFO *pVideoInfo
);
Returns an HRESULT value.
This member function is probably suitable only for specific filters to use. The BITMAPINFO structure has certain fields that are not well specified. In particular, the number of colors specified for a palette can be zero, in which case it is defined to be the maximum for that format type. This member function updates these fields so that their contents are explicit.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.