Compressione dei dati
[La funzionalità associata a questa pagina, Gestione compressione video, è una funzionalità legacy. Microsoft consiglia vivamente che il nuovo codice non usi questa funzionalità.
L'esempio seguente comprime i dati dell'immagine da usare in un file AVI. Presuppone che il compressore non supporti i flag VIDCF_CRUNCH o VIDCF_TEMPORAL, ma supporta VIDCF_QUALITY. Nell'esempio viene utilizzata la macro ICCompressBegin , la funzione ICCompress e la macro ICCompressEnd .
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.
}