int main(int a, char *args[])
{
  	printf("fractal");

	pthread_t thread;

	int tReturn = 0;

	struct arguments{
	  float width;
	  float height;
	  unsigned int *pixmap;
	};

	arguments *toSend = malloc(sizeof(arguments));

	toSend->width = 1024.0f;
	toSend->height = 1024.0f;
	toSend->pixmap = malloc(1024*1024*sizeof(int));

	tReturn = pthread_create(&thread, NULL, mandelbrot, (void*)toSend);

	pthread_join(thread, NULL);

	writetga(toSend->pixmap, 1024, 1024, "fracout.tga");
	free(toSend->pixmap);
	free(toSend);
	return 0;
}
int writeimage(char * name, int xres, int yres, unsigned char *imgdata, 
               int format) {
  if (imgdata == NULL) 
    return IMAGENULLDATA;

  switch (format) {
    case RT_FORMAT_PPM:
      return writeppm(name, xres, yres, imgdata);
    
    case RT_FORMAT_SGIRGB:
      return writergb(name, xres, yres, imgdata);

    case RT_FORMAT_JPEG:
      return writejpeg(name, xres, yres, imgdata);

    case RT_FORMAT_PNG:
      return writepng(name, xres, yres, imgdata);

    case RT_FORMAT_WINBMP:
      return writebmp(name, xres, yres, imgdata);

    case RT_FORMAT_TARGA:
    default:
      return writetga(name, xres, yres, imgdata);       
  } 
}
Beispiel #3
0
int main(int a, char *args[])
{
	int i, j;
	printf("fractal");
	unsigned int* pixmap = malloc(1024*1024*sizeof(int));

    start_timer();
	mandelbrot(1024.0f, 1024.0f, pixmap);
    stop_timer("Calculated mandelbrot.");

    start_timer();
	writetga(pixmap, 1024, 1024, "fracout.tga");
    stop_timer("Written file.");

	free(pixmap);
	return 0;
}