Examen des formats de pixel pris en charge par les appareils

La fonction DescribePixelFormat obtient les données de format de pixel pour un contexte de périphérique. Elle retourne également un entier qui correspond à l’index de format de pixel maximal pour le contexte de périphérique. L’exemple de code suivant montre comment utiliser ce résultat pour parcourir et examiner les formats de pixel pris en charge par un appareil :

// local variables  
int                      iMax ; 
PIXELFORMATDESCRIPTOR    pfd; 
int                      iPixelFormat ; 
 
// initialize a pixel format index variable  
iPixelFormat = 1; 
 
// keep obtaining and examining pixel format data...  
do { 
    // try to obtain some pixel format data  
    iMax = DescribePixelFormat(hdc, iPixelFormat, sizeof(pfd), &pfd); 
 
    // if there was some problem with that...   
    if (iMax == 0) 
     
        // return indicating failure  
        return(FALSE); 
     
    // we have successfully obtained pixel format data  
 
    // let's examine the pixel format data...  
    myPixelFormatExaminer (&pfd); 
    }  
 
// ...until we've looked at all the device context's pixel formats  
while (++iPixelFormat <= iMax);