Guest User

ppm255(3).cpp

a guest
Aug 2nd, 2014
1,111
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // NOTE: compile with g++ filename.cpp -std=c++11
  2.  
  3. #include <iostream>
  4. #include <cmath>
  5. #define DIM 1024
  6. #define DM1 (DIM-1)
  7. #define _sq(x) ((x)*(x))                           // square
  8. #define _cb(x) abs((x)*(x)*(x))                    // absolute value of cube
  9. #define _cr(x) (unsigned char)(pow((x),1.0/3.0))   // cube root
  10.  
  11. unsigned char GR(int,int);
  12. unsigned char BL(int,int);
  13.  
  14. unsigned char RD(int i,int j){
  15.     // YOUR CODE HERE
  16. }
  17. unsigned char GR(int i,int j){
  18.     // YOUR CODE HERE
  19. }
  20. unsigned char BL(int i,int j){
  21.     // YOUR CODE HERE
  22. }
  23.  
  24. void pixel_write(int,int);
  25. FILE *fp;
  26. int main(){
  27.     fp = fopen("MathPic","wb");
  28.     fprintf(fp, "P6\n%d %d\n255\n", DIM, DIM);
  29.     for(int j=0;j<DIM;j++)
  30.         for(int i=0;i<DIM;i++)
  31.             pixel_write(i,j);
  32.     fclose(fp);
  33.     return 0;
  34. }
  35. void pixel_write(int i, int j){
  36.     static unsigned char color[3];
  37.     color[0] = RD(i,j)&255;
  38.     color[1] = GR(i,j)&255;
  39.     color[2] = BL(i,j)&255;
  40.     fwrite(color, 1, 3, fp);
  41. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×