trojanxem

Untitled

Mar 1st, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1.  #include <stdio.h>
  2.  #include <conio.h>
  3.  int main()
  4.   {
  5.         const int szerokosc = 600;
  6.         const int dlugosc = 400;
  7.         int i, j;
  8.         FILE * fp = fopen("obrazek.ppm", "wb");
  9.         fprintf(fp, "P6\n%d %d\n255\n", szerokosc, dlugosc);
  10.         for(j=0; j<dlugosc; ++j)
  11.         {
  12.           for(i=0; i<szerokosc; ++i)
  13.           {        
  14.                         static unsigned char color[3];
  15.                         color[0]=i % 255;
  16.                         color[1]=j % 255;
  17.                         color[2]=(i*j) % 255;
  18.                         fwrite(color,1,3,fp);
  19.                 }
  20.         }
  21.         fclose(fp);
  22.         return 0;
  23.  }
Advertisement
Add Comment
Please, Sign In to add comment