next up previous contents
Next: B.2 Delavec Up: B.1 Upravitelj Previous: B.1.5 Ustavljanje delavcev Vsebina: contents

B.1.6 Shranjevanje rezultatov

Ko je celotna naloga izracunana shranimo datoteko v formatu PPM.

static int
* save_scene ()
* {
* FILE *f;
* int i;

if ((f = fopen (outputFileName, "w")) == NULL)
* {
* perror(outputFileName);
* return -1;
* }

fprintf(f, "P6\n%d %d\n255\n", width, height); /* raw PPM format */
* for (i = jobnext = 0 ; i < njobs; i++)
* {
* int y1, y2;
* y1 = jobnext++ * height; /*
* y1 /= njobs; /*
* y2 = jobnext * height; /* y1 <= y && y < y2 */
* y2 /= njobs; /* y1 is in tile, but y2 is NOT */

fwrite(image[i], (y2 - y1) * width * 3, 1, f);
* }

fflush (f);
* fclose (f);
* return 0;
* }


Copyright © 1995 Leon Kos, Univerza v Ljubljani