-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
46 lines (34 loc) · 1.01 KB
/
Copy pathmain.cpp
File metadata and controls
46 lines (34 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <ctime>
#include "perlin_noise.h"
#define MAX_GREY 255
#define SEED (time(NULL))
int main() {
int WIDTH, HEIGHT, iterations;
printf("Podaj szerokosc: ");
scanf("%d", &WIDTH);
printf("\nPodaj wysokosc: ");
scanf("%d", &HEIGHT);
printf("\nPodaj liczbe iteracji: ");
scanf("%d", &iterations);
printf("\n");
printf("Zaczynam generowac\n");
int *testGREY = (int*)malloc(WIDTH * HEIGHT * sizeof(int));
getNoise(testGREY, WIDTH, HEIGHT, MAX_GREY, iterations, SEED);
printf("Wygenerowano GREY\n");
printf("Zaczynam zapis\n");
FILE *plik;
plik = fopen("tmp.pgm", "w");
fprintf(plik, "P2\n%d %d\n%d\n", WIDTH, HEIGHT, MAX_GREY);
for (int i = 0; i < HEIGHT; i++) {
for (int j = 0; j < WIDTH; j++) fprintf(plik, "%d \t", testGREY[i * WIDTH + j]);
}
printf("Zapisano\n");
printf("Zaczynam zwalniac pamiec\n");
fclose(plik);
free(testGREY);
printf("Zwolnilem pamiec\n");
printf("Koniec\n");
return 0;
}