-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
62 lines (53 loc) · 1.71 KB
/
main.c
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "utils.h"
int main() {
bmp_fileheader fileheader;
bmp_infoheader infoheader;
unsigned int **bitmap = NULL;
infoheader.height = 0;
pen_info pen;
fill_info fill_data;
// command - memoreaza comenzile citite de la tastatura
char *command = calloc(COMM_LEN, sizeof(char));
scanf("%s", command);
// termina atunci cand se citeste "quit"
while (command[0] != 'q') {
switch (command[0]) {
case 's':
if (command[1] == 'a') { // save
save(fileheader, infoheader, bitmap);
} else { // set
set(&pen, &fill_data);
}
break;
case 'e': // edit
edit(&fileheader, &infoheader, &bitmap);
break;
case 'i': // insert
insert(fileheader, infoheader, bitmap);
break;
case 'd': // draw
draw(pen, bitmap, infoheader);
break;
case 'f': // fill
scanf("%d", &fill_data.start_point.y);
scanf("%d", &fill_data.start_point.x);
fill_data.height = infoheader.height;
fill_data.width = infoheader.width;
int i = fill_data.start_point.x;
int j = fill_data.start_point.y;
fill_data.start_color = bitmap[i][j];
fill(&fill_data, bitmap);
break;
default:
break;
}
scanf("%s", command);
}
// dezalocarea memoriei
free(command);
for (unsigned int i = 0; i < infoheader.height; ++i) {
free(bitmap[i]);
}
free(bitmap);
return 0;
}