-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewOptions.cpp
190 lines (167 loc) · 5.86 KB
/
viewOptions.cpp
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#include"header.h";
bool ifRead = false;
bool ifOut = false;
char input[100];
void viewOptions(bmpFileHeader myBmpFileHeader, bmpInfoHeader myBmpInfoHeader,
FILE *newBmpImage,FILE *bmpImage,int padding,pixel image[1000][1000],pixel image_modified[1000][1000],pixel image_temp[1000][1000],int height,int width)
{
int heightOfScreen = GetSystemMetrics(SM_CXSCREEN);
int widthOfScreen = GetSystemMetrics(SM_CYSCREEN);
int gd = DETECT;
int gm;
initwindow(heightOfScreen,widthOfScreen,"Options",-3,-3);
settextstyle(BOLD_FONT,HORIZ_DIR,5);
setcolor(14);
//rectangle(500,100,900,200);
outtextxy(450,130,"Welcome to ImageX");
if(ifRead == false)
{
setcolor(10);
settextstyle(BOLD_FONT,HORIZ_DIR,4);
outtextxy(450,300,"Input an Image First!");
}
else
{
readimagefile(input,600,200,700,300);
}
setcolor(3);
settextstyle(BOLD_FONT,HORIZ_DIR,3);
rectangle(80,400,300,450);
outtextxy(120,415,"INPUT IMAGE");
setbkcolor(BLACK);
rectangle(400,400,600,450);
outtextxy(470,415,"TOOLS");
rectangle(700,400,900,450);
outtextxy(710,415,"RECENT OUTPUT");
rectangle(1000,400,1200,450);
outtextxy(1030,415,"USER MANUAL");
rectangle(1000,550,1200,600);
setcolor(RED);
outtextxy(1080,570,"EXIT");
int count=0;
//getch();
delay(500);
POINT position;
bool flag=false;
while(1)
{
// if(!flag) cout<< "in"<<endl;
flag=true;
if(GetKeyState(VK_LBUTTON)&0x8000)
{
GetCursorPos(&position);
// printf("\n now point is %d %d",position.x,position.y);
count++;
}
if(count==2) break;
}
int x,y;
x = position.x;
y = position.y;
if(x>=100 && x<=300 && y>=400 && y<=470) //input Image
{
closegraph();
delay(500);
ifRead = true;
while(1){
cout<<"Enter the path of the image here : ";
scanf("%s",input);
if(input[strlen(input)-1]!='p' || input[strlen(input)-2]!='m' || input[strlen(input)-3]!='b')
{
cout<<"Wrong File Format!(Input BMP file format)"<<endl;
}
else
break;
}
bmpImage = fopen(input, "rb");
if (bmpImage == NULL)
{
printf("Error occured when opening file\n");
cout<<"Enter the path of the image here : ";
scanf("%s",input);
}
fread(&myBmpFileHeader, sizeof(myBmpFileHeader), 1, bmpImage);
fread(&myBmpInfoHeader, sizeof(myBmpInfoHeader), 1, bmpImage);
if (myBmpFileHeader.bitmapSignatureBytes[0]==0x42 && myBmpFileHeader.bitmapSignatureBytes[1]==0x4D && myBmpInfoHeader.dib_header_size == 40 && myBmpInfoHeader.bits_per_pixel == 24 && myBmpInfoHeader.compression ==0 )
{
printf("\nFile Format is BMP\n");
}
else
{
printf("Error\n");
printf("Error occured when opening file\n");
cout<<"Enter the path of the image here : ";
}
width = myBmpInfoHeader.width;
height = abs(myBmpInfoHeader.height);
for (int i = 0; i < height; ++i)
{
fread(image[i], sizeof(pixel), width, bmpImage);
fseek(bmpImage, padding, SEEK_CUR);
}
viewInput(myBmpFileHeader,myBmpInfoHeader, newBmpImage,bmpImage, width,height,padding,image_modified,input);
viewOptions(myBmpFileHeader,myBmpInfoHeader, newBmpImage,bmpImage, padding, image,image_modified,image_temp,height,width);
}
if(x>=400 && x<=600 && y>=400 && y<=470) //tools
{
if(ifRead == false)
{
int height=300,width=700;
initwindow(width,height,"Input Image Missing!",200,200);
settextstyle(8,HORIZ_DIR,3);
outtextxy(100,100,"PlEASE ENTER AN INPUT IMAGE...");
delay(2000);
closegraph();
viewOptions(myBmpFileHeader,myBmpInfoHeader, newBmpImage,bmpImage, padding, image,image_modified,image_temp,height,width);
}
closegraph();
delay(500);
ifOut = true;
showMainMenu(myBmpFileHeader,myBmpInfoHeader, newBmpImage,bmpImage, padding, image,image_modified,image_temp,height,width);
}
if(x>=700 && x<=900 && y>=400 && y<=470) //recent output
{
if(ifOut == false)
{
int height=300,width=700;
initwindow(width,height,"Output Image Missing!",200,200);
settextstyle(8,HORIZ_DIR,3);
outtextxy(100,100,"PlEASE EDIT AN IMAGE FIRST!");
delay(2000);
closegraph();
viewOptions(myBmpFileHeader,myBmpInfoHeader, newBmpImage,bmpImage, padding, image,image_modified,image_temp,height,width);
}
else
{
char s[100] = "image1.bmp";
viewInput(myBmpFileHeader,myBmpInfoHeader, newBmpImage,bmpImage, width,height,padding,image_modified,s);
closegraph();
viewOptions(myBmpFileHeader,myBmpInfoHeader, newBmpImage,bmpImage, padding, image,image_modified,image_temp,height,width);
}
}
if(x>=1000 && x<=1200 && y>=400 && y<=470)//user manual
{
closegraph();
system("userManual.txt");
cout<<"Press Enter"<<endl;
getchar();
viewOptions(myBmpFileHeader,myBmpInfoHeader, newBmpImage,bmpImage, padding, image,image_modified,image_temp,height,width);
}
if(x>=1000 && x<=1200 && y>=550 && y<=650)//exit
{
//closegraph();
int height=300,width=700;
initwindow(width,height,"Exiting",200,200);
settextstyle(8,HORIZ_DIR,3);
outtextxy(100,100,"THANK YOU FOR USING THE SYSTEM...");
delay(2000);
closegraph();
fclose(bmpImage);
free(image);
free(image_temp);
free(image_modified);
exit(1);
}
_getch();
closegraph();
}