// // Torbert, 7 March 2016 // // gcc -fopenmp writeppm.c // // time ./a.out // // real 0m1.554s // user 0m5.843s // #include // #define M 640 #define N 480 // typedef struct { int r ; // red int g ; // green int b ; // blue // } color ; // void getColor( color* h ) ; // int main(void) { int rgb[N][M][3] ; // red-green-blue for each pixel // int y , x ; // color h ; // the pixel's color // FILE* fout ; // for( y = 0 ; y < N ; y++ ) { #pragma omp parallel for private(x,h) for( x = 0 ; x < M ; x++) { h.r = 178 ; // background ... Italian Sky Blue h.g = 255 ; h.b = 255 ; // getColor( &h ) ; // rgb[y][x][0] = h.r ; // red rgb[y][x][1] = h.g ; // green rgb[y][x][2] = h.b ; // blue } } // fout = fopen( "allgreen.ppm" , "w" ) ; // fprintf( fout , "P3\n" ) ; fprintf( fout , "%d %d\n" , M , N ) ; fprintf( fout , "255\n" ) ; // for( y = 0 ; y < N ; y++ ) { for( x = 0 ; x < M ; x++) { fprintf( fout , "%d %d %d\n" , rgb[y][x][0] , rgb[y][x][1] , rgb[y][x][2] ) ; } } fclose( fout ) ; // return 0 ; } // void getColor( color* h ) { int j ; // for( j = 0 ; j < 10000 ; j++ ) ; // bogus // h->r = 0 ; h->g = 255 ; h->b = 0 ; } // // end of file //