//*************************************// //******** created by mamo139 *********// //*** http://mamo139.altervista.org ***// //*************************************// #include #include #include #include char *** crea_bmp(char *nome, long x, long y); void disegna_bmp(char *nome, char *** array, long x, long y); struct complesso { double r; double i; }; //*** strumenti gestione colori ***// struct rgb { int red; int green; int blue; }; struct rgb_d { double red; double green; double blue; }; struct hsv { int hue; int saturation; int value; }; struct rgb hsv_rgb(struct hsv hsv_map); //****** MAIN *******// int main (void){ char immagine_name[]="buddha_hsv.bmp"; //*********** PARAMETRI *************// long larghezza = 1000; long altezza = 1000; long deep = 10000; long buddha = 1000000; double y1 = 2; double x0 = -2, x1 = 2; double y0 = -2; //**********************************// //aggiustamento parametri double agg_temp; agg_temp=y1; y1=y0*(-1); y0=agg_temp*(-1); //**********************************// time_t t; srand((unsigned) time(&t)); long b=0; long x,y; char *** matrice; matrice = crea_bmp(immagine_name,larghezza,altezza); long ** buddha_value; buddha_value = (long**) malloc(larghezza * sizeof(long *)); for(b=0; b 4) { d = i; break; } temp.r = z.r; temp.i = z.i; z.r = (temp.r*temp.r) - (temp.i*temp.i) + c.r; z.i = (temp.r*temp.i)*2 + c.i; history[i].r = z.r; history[i].i = z.i; } //controllo punto dell'insieme di mendelbrot if(d!=0) { for(a=0;a0 && x0 && ygrande) grande = buddha_value[x][y]; if(buddha_value[x][y] 255) buddha_value[x][y] = 255; hsv_map.hue = 50; hsv_map.saturation = 200; hsv_map.value = buddha_value[x][y]; rgb_map = hsv_rgb(hsv_map); matrice[x][y][2]= rgb_map.red; matrice[x][y][1]= rgb_map.green; matrice[x][y][0]= rgb_map.blue; } printf("fine colorazione, inizio scrittura!\n"); disegna_bmp(immagine_name,matrice,larghezza,altezza); printf("fine!"); system(immagine_name); //getchar(); return 0; } char *** crea_bmp(char *nome, long x, long y){ FILE *stream, *cavia; stream = fopen(nome,"wb"); cavia = fopen("cavia","rb"); char *buffer; buffer = (char *)malloc(54 * sizeof(char)); long b = fread( buffer, 1, 54, cavia); buffer[18] = x%256;//asse x buffer[19] = x/256; buffer[22] = y%256;//asse y buffer[23] = y/256; fwrite(buffer, 1, b, stream); fclose(stream); char *** array; int i, j, h; array = (char***)malloc(x * sizeof(char *)); for(i=0; i=0; i2--) for(i1=0; i1