Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. int blackAndWhiteInt(SDL_Surface *surf,int x,int y,int contrast)
  2. {
  3.   Uint8 r, g, b;
  4.   SDL_GetRGB(getPixel(surf,x,y),surf->format, &r,&g,&b);
  5.   Uint8 compt = r * 0.3 + g * 0.59 + b * 0.11;
  6.   if((int)compt >= contrast) return 0;
  7.   else return 1;
  8. }
  9.  
  10. /*Créer un tableau de int dans lequel sont insere les pixels:
  11.  * 1 = noir, 0 = blanc.*/
  12. int *tabs(int *tab,SDL_Surface *surf,int contrast)
  13. {
  14.   int w = surf->w;
  15.   int h = surf->h;
  16.   for(int y= 0;y<h;y++)
  17.   {
  18.     for(int x= 0;x<w;x++)
  19.     {
  20.       int pi = 2;
  21.       pi = blackAndWhiteInt(surf,x,y,contrast);
  22.       tab[y*w+x]=pi;
  23.     }
  24.   }
  25.   return tab;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement