-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFloodFill_FunctionFile.c
More file actions
77 lines (64 loc) · 1.48 KB
/
FloodFill_FunctionFile.c
File metadata and controls
77 lines (64 loc) · 1.48 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "queues.h"
typedef struct s{
coordinates x,y;
}Coordinate_t;
Coordinate_t QueueList[MAXROW*MAXCOL];
QueueItem picture[MAXCOL][MAXROW];
int Rear,Front ;
// these are for the QueueList
void newQueue(){
Rear = Front = 0;
}
void makeOriginal(){
for(int i = 0;i < MAXCOL;i++){
for(int j = 0;j <MAXROW;j++)
scanf("%d",&picture[i][j]);
}
}
void enqueue(coordinates x1, coordinates y1){
if(isFull())
return;
QueueList[Rear].x = x1;
QueueList[Rear].y = y1;
Rear++;
}
coordinates dequeue(coordinates *x1 ,coordinates y){
if(isEmpty())
return INVALID;
*x1 = QueueList[Front].x;
return QueueList[Front++].y;
}
pixel_t returnPixel(coordinates x,coordinates y){
if(isBigSmall(x,y)){
printf("Sorry wrong input %d\n",picture[y][x]);
return INVALID;
}
return picture[y][x];
}
void unconnect(coordinates x1,coordinates y1){
picture[y1][x1] = 0;
}
int checkPixel(coordinates x1,coordinates y1, pixel_t pixel){
if(isBigSmall(x1,y1)){
return 0;
}
if(picture[y1][x1] == pixel){
return 1;
}else return 0;
}
void print(){
for(int i = 0;i < MAXCOL;i++){
for(int j = 0;j <MAXROW;j++)
printf("%d",picture[i][j]);
printf("\n");
}
}
int isEmpty(){
return Rear == Front;
}
int isFull(){
return Rear == MAXROW*MAXCOL;
}
int isBigSmall(coordinates x,coordinates y){
return !((x > -1 && x < MAXROW) && (y > -1 && y <MAXCOL));
}