Comment declarée la matrice matrix[x][y]

pirate75000 Messages postés 55 Date d'inscription lundi 23 octobre 2000 Statut Membre Dernière intervention 6 août 2006 - 17 juil. 2003 à 22:36
cs_payen Messages postés 252 Date d'inscription mercredi 25 octobre 2000 Statut Membre Dernière intervention 1 mai 2005 - 17 juil. 2003 à 22:54
Comment declarée la matrice matrix[x][y]
Le but est de remplir la matirce avec le Tableau Tab
puis effectuer une inversion video par matrice
puis réécrit le fichier image

Je pense qu'il doit avoir plus simple pour une inversion vidéo
mais j'aurais bessoin d'autre fonction en matrice,
comme cela j'aurais un model je pourrais me débrouiller
Merci

int CorrigeImg (char* NomIn, char* NomOut)
{
    //Déclaration des variables
    FILE* pFic;
    BYTE* Tab = NULL;
    int width;        //la taille d' une ligne en octets
    int NbPpl,Nbl,width,i,x,y;

    BITMAPFILEHEADER* BmpHeadEtal = NULL;
    BITMAPINFO* BmpInfoEtal = NULL;
    //Read picture
    BmpHeadEtal = (BITMAPFILEHEADER*) new BYTE [14];
    BmpInfoEtal = (BITMAPINFO*)new BYTE [sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD)];    if ((pFic fopen(NomIn,"rb")) NULL)
        return ERROR_OPEN;
    if ((fread (BmpHeadEtal, 1, 14, pFic)) != 14)            
        return ERROR_READ;
    if ((fread (BmpInfoEtal, 4, 10+256, pFic)) != 266)        
        return ERROR_READ;                            
    NbPpl = BmpInfoEtal->bmiHeader.biWidth;
    Nbl = BmpInfoEtal->bmiHeader.biHeight;
    width = WIDTHBYTES(NbPpl * 8);        // DWORD Align
    Tab = new BYTE [width*Nbl];
    if (fread (Tab, 1, (width*Nbl), pFic) != width*Nbl)
        return ERROR_READ;
    if (fclose (pFic))
        return ERROR_CLOSE;

    //Dib -> Matrice
    for (int y=0;y<Nbl;y++){
        for(int x;x<width;x++){
            matrix[x][y]=Tab[x+y*width];
        }
    }
    //On traite la matrice pour inversion vidéo

    //Matrice -> Dib
    for (int y=0;y<Nbl;y++){
        for(int x;x<width;x++){
            Tab[x+y*width]=matrix[x][y];
        }
    }
    //Ecriture de l'image    if ((pFic fopen(NomOut,"wb")) NULL)    
        return ERROR_OPEN;
    if ((fwrite (BmpHeadEtal, 1, 14, pFic)) != 14)            
        return ERROR_WRITE;
    if ((fwrite (BmpInfoEtal, 4, 10+256, pFic)) != 266)        
        return ERROR_WRITE;                            
    if (! (fwrite (Tab, 1, (width*Nbl), pFic)))
        return ERROR_WRITE;
    if (fclose (pFic))
        return ERROR_CLOSE;
}

1 réponse

cs_payen Messages postés 252 Date d'inscription mercredi 25 octobre 2000 Statut Membre Dernière intervention 1 mai 2005
17 juil. 2003 à 22:54
si tu veux la declarer en dynamique, tu peux aller voir la premiere fonction de ma source (mon unique !!!) : http://www.cppfrance.com/article.aspx?Val=2094
0
Rejoignez-nous