Guest User

Untitled

a guest
Jan 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. /*
  2. Ma structure
  3. */
  4.  
  5. typedef struct  {
  6.     int dimx;/*!<  Largeur de l'image */
  7.     int dimy; /*!<  Hauteur de l'image */
  8.     pixel * tab; /*!<  Tableau de pixels qui composent l'image */
  9. } image;
  10.  
  11.  
  12. /*
  13. Initialise la structure image et alloue la mémoire dans le tas
  14. */
  15.  
  16. void imInit(image * im,int dimx, int dimy)
  17. {
  18.     assert(dimx > 0 && dimy > 0);
  19.     im->tab = (pixel *)malloc(sizeof(pixel)*dimx*dimy);
  20.     im->dimx = dimx;
  21.     im->dimy = dimy ;
  22. }
  23.  
  24. /*
  25. Libère la mémoire
  26. */
  27. void imLibere(image * im)
  28. {
  29.     int i,maxT;
  30.     maxT = im->dimx*im->dimy;
  31.     for (i=0;i<maxT;i++)
  32.     {
  33.         free(im->tab[i]);
  34.     }
  35.  
  36.     im->dimx=0;
  37.     im->dimy=0;
  38. }
Add Comment
Please, Sign In to add comment