Komprimieren von Daten
[Das dieser Seite zugeordnete Feature Videokomprimierungs-Manager ist ein Legacyfeature. Microsoft empfiehlt dringend, dass neuer Code dieses Feature nicht verwendet.]
Im folgenden Beispiel werden Bilddaten für die Verwendung in einer AVI-Datei komprimiert. Es wird davon ausgegangen, dass der Kompressor die VIDCF_CRUNCH- oder VIDCF_TEMPORAL-Flags nicht unterstützt, aber VIDCF_QUALITY unterstützt. Das Beispiel verwendet das ICCompressBegin-Makro , die ICCompress-Funktion und das ICCompressEnd-Makro .
DWORD dwCkID;
DWORD dwCompFlags;
DWORD dwQuality;
LONG lNumFrames, lFrameNum;
// Assume dwNumFrames is initialized to the total number of frames.
// Assume dwQuality holds the proper quality value (0-10000).
// Assume lpbiOut, lpOut, lpbiIn, and lpIn are initialized properly.
// If OK to start, compress each frame.
if (ICCompressBegin(hIC, lpbiIn, lpbiOut) == ICERR_OK)
{
for ( lFrameNum = 0; lFrameNum < lNumFrames; lFrameNum++)
{
if (ICCompress(hIC, 0, lpbiOut, lpOut, lpbiIn, lpIn,
&dwCkID, &dwCompFlags, lFrameNum,
0, dwQuality, NULL, NULL) == ICERR_OK)
{
// Write compressed data to the AVI file.
// Set lpIn to the next frame in the sequence.
}
else
{
// Handle compressor error.
}
}
ICCompressEnd(hIC); // terminate compression
}
else
{
// Handle the error identifying the unsupported format.
}