begin process at 2012 05 29 06:23:08
  Trouver un code source :
 
dans
 
Accueil > Forum > 

C

 > 

Divers

 > 

Général

 > 

error LNK2001: unresolved external symbol _WinMainCRTStartup


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

error LNK2001: unresolved external symbol _WinMainCRTStartup

lundi 21 février 2011 à 19:28:15 | error LNK2001: unresolved external symbol _WinMainCRTStartup

CrKa

slt,j'ai cette erreur dans mon programme en VC++ erreur

1>------ Rebuild All started: Project: test4, Configuration: Debug Win32 ------
1>LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
1>d:\documents and settings\ayoub\mes documents\visual studio 2010\Projects\test4\Debug\test4.exe : fatal error LNK1120: 1 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

comment fixer cette erreur de liker??


//A GRAPHICS PROJECT BY JAGAT SASTRY P. & CHARITH CHOWDARY K.P.//
//2ND YEAR COMPUTER ENGINEERING//
//NITK SURATHKAL//

//NOTE TO USERS: CHANGE THE BGI DIRECTORY TO THAT OF YOURS(LINE 2926)//

#include<dos.h>
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<alloc.h>




#define MIN_X 83
#define MAX_X 629
#define MIN_Y 35
#define MAX_Y 409
#define MAX_BUTTONS 27
#define MAX_COLPAT 28
int check_mouse_on(int,int,int,int);
void quit();
void end_about();
void init_button(int,int,int,int,int,char*,int);
void init_color_button(int,int,int,int,int,int);
void draw_button_border(int );
void undraw_button_border(int no);
void draw_color_button_border(int,int);
void disp_coord();
void getxy();
void topic();
void ffill(int x,int y,int backColor,int fill_color);
void DDA_line(int,int,int,int,int);
void algoellipse(int,int,float,float);
void plotellipsepoints(int,int,int,int);
int over(int,int,int,int);
void unmark();
void translate();
void rotate();
void scale();
char* readline(char*);
void about();
void create_box(int,int,int,int,int,int,int);
void new_file();
void save();
void load();
void dark();
void light();
void invert();
void blackwhite();

void ShowStatus(char*);
void ClearStatus();
void beep();

void Line_ico(int x1, int y1);
void Rectangle_ico(int x1, int y1);
void Circle_ico(int x1, int y1);
void Spiral_ico(int x1,int y1);
void Brush_ico(int x1, int y1);
void Erase_ico(int x1, int y1);
void Bucket_ico(int x,int y);
void Cube_ico(int x, int y);
void Sphere_ico(int x1, int y1);
void Mark_ico(int x1, int y1);
void Clip_ico(int x1, int y1);
void Alphabet_ico(int x, int y);
void Ellipse_ico(int x1,int y1);
void Del_ico(int x1,int y1);
int button,x,y;
int LeftButtonPressed;
int RightButtonPressed;
int precolflag;
int prevx,prevy;
int mousex,mousey;
int Current_Color=BLACK; /*/ to Store the current color */
int Current_Pattern=EMPTY_FILL;/*/ to store the current Pattern*/
int Current_Button=5;/*/ to store the current button pressed*/
int Prev_Button=4;/*/ to store the previous button */
int saved=0;
char FileName[40]="Untitled";
int previ=Current_Button;
union REGS i,o;

char buffer1[40000];

struct
{
int top,left,bottom,right;
}marker;

int marked=0; /*/ to store whether marked or not*/

int initmouse()
{
i.x.ax=0;
int86(0x33,&i,&o);
return(o.x.ax);
}
void showmouseptr()
{
i.x.ax=1;
int86(0x33,&i,&o);
}
void hidemouseptr()
{
i.x.ax=2;
int86(0x33,&i,&o);
}
void startmouse(int x,int y)
{
i.x.ax=4;
i.x.cx=x;
i.x.dx=y;
int86(0x33,&i,&o);
}

void getxy()
{
union REGS regs;
regs.x.ax=3;
int86(0x33,&regs,&regs);

prevx=mousex;
prevy=mousey;
if(regs.x.bx&1)
LeftButtonPressed=1;
else
LeftButtonPressed=0;
if(regs.x.bx&2)
RightButtonPressed=1;
else
RightButtonPressed=0;

mousex=regs.x.cx;
mousey=regs.x.dx;
}



void cut()
{


ShowStatus("do not cut large areas");
if(marked)
{

unmark();
//int height=marker.bottom-marker.top;
//int length=marker.right-marker.left;
//int area=imagesize(marker.left,marker.top,marker.right,marker.bottom);
//buffer1=(int*)malloc(sizeof(int)*(height*length+20));
//buffer1[0]=length;
//buffer1[1]=height;
int i,j,k=0;
for(i=marker.top;i<marker.bottom;i++)
for(j=marker.left;j<marker.right;j++)
buffer1[k++]=getpixel(j,i);

hidemouseptr();
for(i=marker.left;i<marker.right;i++)
for(j=marker.top;j<marker.bottom;j++)
{

putpixel(i,j,WHITE);
}
showmouseptr();

}
}
//int *buffer;
void copy()
{

ShowStatus("do not copy large areas");
if(marked)
{
unmark();
int height=marker.bottom-marker.top;
int length=marker.right-marker.left;
//int area=imagesize(marker.left,marker.top,marker.right,marker.bottom);
//buffer1=(int*)malloc(sizeof(int)*(height*length+20));
buffer1[0]=length;
buffer1[1]=height;
int i,j,k=0;
for(i=marker.top;i<marker.bottom;i++)
for(j=marker.left;j<marker.right;j++)
buffer1[k++]=getpixel(j,i);


}
}

void paste(int x1,int y1)
{
int i,j,xt,yt,k=0;
//int height=buffer1[1];
//int length=buffer1[0];
//printf("hello");
hidemouseptr();
int h=marker.bottom-marker.top;
int l=marker.right-marker.left;
for(i=y1;i<y1+h;i++)
for(j=x1;j<x1+l;j++)
{
if(j>MIN_X && j<MAX_X && i>MIN_Y && i<MAX_Y)
putpixel(j,i,buffer1[k++]);
}
showmouseptr();
//free(buffer1);
}


void callpaste()
{
delay(500);
LeftButtonPressed=0;
while(1)
{
getxy();
if(LeftButtonPressed)
{
//printf("hi");
if(mousex<MIN_X || mousex>MAX_X || mousey<MIN_Y || mousey>MAX_Y)
return ;
paste(mousex,mousey);
return ;
}

else if(RightButtonPressed)
return;
}

}




void getmousepos(int *button,int *x,int *y)
{
i.x.ax=3;
int86(0x33,&i,&o);
*button=o.x.bx;
if(o.x.bx&1)
LeftButtonPressed=1;
else
LeftButtonPressed=0;
if(o.x.bx&2)
RightButtonPressed=1;
else
RightButtonPressed=0;
prevx=mousex;
prevy=mousey;
mousex=o.x.cx;
mousey=o.x.dx;
*x=o.x.cx;
*y=o.x.dx;
}

int buttclicked()
{
union REGS regs;
regs.x.ax=3;
int86(0x33,&regs,&regs);
return regs.x.bx;
}

void wheremouse(int *x,int*y)
{
union REGS regs;
regs.x.ax=3;
int86(0x33,&regs,&regs);
*x=regs.x.cx;
*y=regs.x.dx;
}

void restrictmouseptr(int x1,int y1,int x2,int y2)
{
i.x.ax=7;
i.x.cx=x1;
i.x.dx=x2;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=y1;
i.x.dx=y2;
int86(0x33,&i,&o);
}

/* This if the description of the tooolbar button */
typedef struct button_desc
{
int xmin,ymin,xmax,ymax;
int button_no;
char* desc;
int popup;
}tool_but;

tool_but buttons[MAX_BUTTONS];

/* This is the description of the color button */
typedef struct color_button
{
int xmin,ymin,xmax,ymax;
int color;
int colflag;
}color_but;

color_but colorbuttons[28];



void freehand()
{
setcolor(Current_Color);
if(prevx<MIN_X+2||prevx>MAX_X-2||prevy>MAX_Y-2||prevy<MIN_Y+2)
return;

while(LeftButtonPressed)
{

disp_coord();

line(mousex,mousey,prevx,prevy);
getxy();

}
}

void erase()
{
int i,j;
while(LeftButtonPressed)
{

disp_coord();
for(i=mousex;i<mousex+10&&i<=MAX_X-2;++i)
for(j=mousey;j<mousey+10&&j<=MAX_Y-2;++j)
putpixel(i,j,WHITE);
getmousepos(&button,&x,&y);

}
}

void drawline()
{
int color=15-Current_Color;
int x,y;
setcolor(color);
setwritemode(XOR_PUT);

x=mousex;
y=mousey;

if(x<MIN_X+2||x>MAX_X-2||y>MAX_Y-2||y<MIN_Y+2)
return;

while(LeftButtonPressed)
{
getxy();
if(mousex!=prevx||mousey!=prevy)
{
disp_coord();
line(x,y,prevx,prevy);
line(x,y,mousex,mousey);
}
}
setwritemode(COPY_PUT);
setcolor(Current_Color);
line(x,y,mousex,mousey);

}

void drawrectangle()
{
int color=15-Current_Color;
int x,y;
setcolor(color);
setwritemode(XOR_PUT);

x=mousex;
y=mousey;

while(LeftButtonPressed)
{
getxy();
if(mousex!=prevx||mousey!=prevy)
{
disp_coord();
rectangle(x,y,prevx,prevy);
rectangle(x,y,mousex,mousey);
}
}
setwritemode(COPY_PUT);
setcolor(Current_Color);
if(Current_Pattern==EMPTY_FILL)
rectangle(x,y,mousex,mousey);
else
{
setfillstyle(Current_Pattern,Current_Color);
bar(x,y,mousex,mousey);
}
}

void drawtext()
{
int size=0,max_char,i=0;
char ch;
char str[68]; /*/ ( (MAX_X-2)-(MIN_X+2) )/8 ,8 being width & height of a char*/
char blank[68]; /*/ to write blank*/

max_char=(MAX_X-2-mousex)/8;
if((MAX_Y-2-mousey<9) || (max_char<1))
{
ShowStatus(" Not Enough Space to Write ");
beep();
ClearStatus();
return;
}

ShowStatus("Press <Enter> or <Esc> to exit");
fflush(stdin);
str[0]='\0';

ch=getch();

while(ch!=13 && ch!=27)
{
if (ch==8)
{
if(size<1)
beep();
else
{
setcolor(WHITE);
strcpy(blank,"");
for(i=0;i<size;++i)
blank[i]='&#1594;';
blank[size]='\0';
outtextxy(mousex,mousey,blank);

setcolor(Current_Color);
size--;
str[size]='\0';
outtextxy(mousex,mousey,str);
}
}
else if(size==max_char)
{
beep();
}
else
{
size++;
setcolor(WHITE);
strcpy(blank,"");
for(i=0;i<size;++i)
blank[i]='&#1594;';
blank[size]='\0';
outtextxy(mousex,mousey,blank);

str[size-1]=ch;
setcolor(Current_Color);
str[size]='\0';
outtextxy(mousex,mousey,str);
}
ch=getch();
}
ClearStatus();
}

struct node1
{
int x,y;
struct node1* next;
};
struct node1 *last1,*root1,*p1;

void insert(int x,int y)
{
struct node1 *new1;
new1=(struct node1*)malloc(sizeof(struct node1));
new1->x=x;
new1->y=y;
new1->next=NULL;
last1->next=new1;
last1=new1;
return;
}


void Bucket()
{
int x,y,bgcolor;
while(LeftButtonPressed)
{
disp_coord();
getxy();
}
setwritemode(COPY_PUT);
x=mousex;
y=mousey;
bgcolor=getpixel(x,y);
ffill(x,y,bgcolor,Current_Color);
}

void ffill(int x,int y,int backColor,int fill_color)
{
if(backColor==fill_color)
return;
last1=root1=(struct node1*)malloc(sizeof(struct node1));
root1->x=x;
root1->y=y;
root1->next=NULL;
while(root1!=NULL)
{
if(x<MAX_X&&y<MAX_Y&&x>MIN_X&&y>MIN_Y)
putpixel(x,y,fill_color);
if(getpixel(x,y-1)==backColor)
{
if(x<MAX_X&&y-1<MAX_Y&&x>MIN_X&&y-1>MIN_Y)
{
putpixel(x,y-1,fill_color);
insert(x,y-1);
}
}
if(getpixel(x+1,y)==backColor)
{
if(x+1<MAX_X&&y<MAX_Y&&x+1>MIN_X&&y>MIN_Y)
{
putpixel(x+1,y,fill_color);
insert(x+1,y);
}
}
if(getpixel(x,y+1)==backColor)
{
if(x<MAX_X&&y+1<MAX_Y&&x>MIN_X&&y+1>MIN_Y)
{
putpixel(x,y+1,fill_color);
insert(x,y+1);
}
}
if(getpixel(x-1,y)==backColor)
{
if(x-1<MAX_X&&y<MAX_Y&&x-1>MIN_X&&y>MIN_Y)

{
putpixel(x-1,y,fill_color);
insert(x-1,y);
}
}
p1=root1;
root1=root1->next;
free(p1);
x=root1->x;
y=root1->y;
}
}

void beep()
{
sound(7);
delay(1000);
nosound();
}

void ShowStatus(char* str)
{
int color=getcolor();
int i;

ClearStatus();
setcolor(BLACK);
outtextxy(12,464,str);
setcolor(color);
}

void Cube()
{
int color=15-Current_Color;
int temp,x,y,mousex1,mousey1;
restrictmouseptr((MIN_X+5),(MIN_Y+5),(MAX_X-30),(MAX_Y-30));
setcolor(color);
setwritemode(XOR_PUT);

x=mousex;
y=mousey;

while(LeftButtonPressed)
{
disp_coord();
getxy();
}
setwritemode(COPY_PUT);
mousex1=mousex;
mousey1=mousey;
if(mousex1<x || mousey1<y)
{
temp=x;
x=mousex1;
mousex1=temp;
temp=y;
y=mousey1;
mousey1=temp;
}
if(mousex1-x>1 && mousey1-y>1)
{
if(Current_Pattern==EMPTY_FILL)
{
setcolor(Current_Color);
rectangle(x,y,mousex1,mousey1);
rectangle(x+25, y+25, mousex1+25, mousey1+25);
line(x,y,x+25,y+25);
line(mousex1,mousey1,mousex1+25,mousey1+25);
line(x,mousey1,x+25,mousey1+25);
line(mousex1,y,mousex1+25,y+25);
}
else
{
setfillstyle(Current_Pattern,Current_Color);
bar(x,y,mousex1,mousey1);
bar(x+25, y+25, mousex1+25, mousey1+25);
setcolor(BLACK);
rectangle(x,y,mousex1,mousey1);
rectangle(x+25, y+25, mousex1+25, mousey1+25);
line(x,y,x+25,y+25);
line(mousex1,mousey1,mousex1+25,mousey1+25);
line(x,mousey1,x+25,mousey1+25);
line(mousex1,y,mousex1+25,y+25);
floodfill(mousex1+5,y+10,BLACK);
floodfill(x+10,mousey1+5,BLACK);
floodfill(mousex1+2,mousey1,BLACK);
}
}
restrictmouseptr(0,0,640,480);
}

void drawellipse()
{
int x1,y1,x2,y2,color,xmid,ymid;
float radx,rady;
x1 = mousex;
y1 = mousey;
radx=rady=1;
setwritemode(XOR_PUT);
while(LeftButtonPressed)
{
getxy();
if(mousex!=prevx||mousey!=prevy)
{
algoellipse(xmid,ymid,radx,rady);
disp_coord();
x2 = mousex;
y2 = mousey;
xmid = (x1 + x2)/2;
ymid = (y1 + y2)/2;
radx = abs((x2 - x1)/2);
rady = abs((y2 - y1)/2);
if (radx < 1)
radx = 1;
if (rady < 1)
rady = 1;
color = 15 - Current_Color;
setcolor(color);
algoellipse(xmid,ymid,radx,rady);
//delay(50);
//algoellipse(xmid,ymid,radx,rady);
}
}
setwritemode(COPY_PUT);
setcolor(Current_Color);
x2 = mousex;
y2 = mousey;
xmid = (x1 + x2)/2;
ymid = (y1 + y2)/2;
radx = abs((x2 - x1)/2);
rady = abs((y2 - y1)/2);
if(Current_Pattern==EMPTY_FILL)
algoellipse(xmid,ymid,radx,rady);
else
{
setfillstyle(Current_Pattern,Current_Color);
fillellipse(xmid,ymid,radx,rady);
}

}


void algoellipse(int xcen,int ycen,float radx,float rady)
{
float p,px,py,x,y,ry,rx,tworx,twory;
ry = rady * rady;
rx = radx * radx;
twory = 2 * ry;
tworx = 2 * rx;
x = 0;
y = rady;
plotellipsepoints(xcen,ycen,x,y);
p = (ry - rx*rady + (0.25 * rx));
px = 0;
py = tworx * y;
while (px < py)
{ x++;
px = px + twory;
if (p >= 0)
{ y--;
py = py - tworx;
}
if (p < 0)
p = p + ry + px;
else
p = p + ry + px - py;
plotellipsepoints(xcen,ycen,x,y);
}
p = (ry * (x + 0.5) * (x + 0.5) + rx * (y-1) * (y-1) - rx * ry);
while (y > 0)
{ y--;
py = py - tworx;
if (p <= 0)
{ x++;
px = px + twory;
}
if (p > 0)
p = p + rx - py;
else
p = p + rx - py + px;
plotellipsepoints(xcen,ycen,x,y);
}
}

void plotellipsepoints(int xcen,int ycen,int x,int y)
{
if (xcen+x >= MIN_X && xcen+x <= MAX_X && ycen+y >= MIN_Y && ycen+y <= MAX_Y)
line(xcen+x,ycen+y,xcen+x,ycen+y);
if (xcen-x >= MIN_X && xcen-x <= MAX_X && ycen+y >= MIN_Y && ycen+y <= MAX_Y)
line(xcen-x,ycen+y,xcen-x,ycen+y);
if (xcen+x >= MIN_X && xcen+x <= MAX_X && ycen-y >= MIN_Y && ycen-y <= MAX_Y)
line(xcen+x,ycen-y,xcen+x,ycen-y);
if (xcen-x >= MIN_X && xcen-x <= MAX_X && ycen-y >= MIN_Y && ycen-y <= MAX_Y)
line(xcen-x,ycen-y,xcen-x,ycen-y);
}

void algospiral(int xcen,int ycen,float radx,float rady)
{
float rx=5,ry=5;
while(rx<radx || ry<rady)
{
ellipse( xcen, ycen, 90, 270, rx, ry );
rx += 5;
ry += 5;
ycen -= 5;
ellipse( xcen, ycen, 270, 90, rx, ry );
rx += 5;
ry += 5;
ycen += 5;
}
}

void drawspiral()
{
int x1,y1,x2,y2,color,xmid,ymid;
float radx;
x1 = mousex;
y1 = mousey;
radx=1;
setwritemode(XOR_PUT);
while(LeftButtonPressed)
{
disp_coord();
x2 = mousex;
y2 = mousey;
xmid = (x1 + x2)/2;
ymid = (y1 + y2)/2;
radx = abs((x2 - x1)/2);
if (radx < 1)
radx = 1;
color = 15 - Current_Color;
setcolor(color);
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+8))
radx=ymid-(MIN_Y+8);
algoellipse(xmid,ymid,radx,radx);
delay(20);
getxy();
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+8))
radx=ymid-(MIN_Y+8);
algoellipse(xmid,ymid,radx,radx);
}
setwritemode(COPY_PUT);
setcolor(Current_Color);
x2 = mousex;
y2 = mousey;
xmid = (x1 + x2)/2;
ymid = (y1 + y2)/2;
radx = abs((x2 - x1)/2);
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+8))
radx=ymid-(MIN_Y+8);
/*circle(xmid,ymid,radx);*/
algospiral(xmid,ymid,radx,radx);
}

void drawcircle()
{
int x1,y1,x2,y2,color,xmid,ymid;
float radx;
x1 = mousex;
y1 = mousey;
setwritemode(XOR_PUT);
while(LeftButtonPressed)
{
disp_coord();
x2 = mousex;
y2 = mousey;
xmid = (x1 + x2)/2;
ymid = (y1 + y2)/2;
radx = abs((x2 - x1)/2);
if (radx < 1)
radx = 1;
color = 15 - Current_Color;
setcolor(color);
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+2))
radx=ymid-(MIN_Y+2);
algoellipse(xmid,ymid,radx,radx);
/* circle(xmid,ymid,radx); */
delay(20);
getxy();
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+2))
radx=ymid-(MIN_Y+2);
algoellipse(xmid,ymid,radx,radx);
/* circle(xmid,ymid,radx); */
}
setwritemode(COPY_PUT);
setcolor(Current_Color);
x2 = mousex;
y2 = mousey;
xmid = (x1 + x2)/2;
ymid = (y1 + y2)/2;
radx = abs((x2 - x1)/2);
if(Current_Pattern==EMPTY_FILL)
{
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+2))
radx=ymid-(MIN_Y+2);
/*circle(xmid,ymid,radx);*/
algoellipse(xmid,ymid,radx,radx);

}
else
{
setfillstyle(Current_Pattern,Current_Color);
if((xmid+radx)>(MAX_X-2))
radx=(MAX_X-2)-xmid;
if((xmid-radx)<(MIN_X+2))
radx=xmid-(MIN_X+2);
if((ymid+radx)>(MAX_Y-2))
radx=(MAX_Y-2)-ymid;
if((ymid-radx)<(MIN_Y+2))
radx=ymid-(MIN_Y+2);
fillellipse(xmid,ymid,radx,radx);
}

}

void sphere()
{
int i,r;
int px,py;
int ex,ey;

setcolor(Current_Color);

if(over(40,50,MAX_X-60,MAX_Y-65)==0)return;
{

wheremouse(&mousex,&mousey);
px=mousex;py=mousey;
setwritemode(XOR_PUT);
if(over(40,50,MAX_X-60,MAX_Y-65)==0)return;

if(buttclicked()==1)
while(1)
{

hidemouseptr();
line(px,py,px,mousey);/* pxpy mxpy */
line(px,py,mousex,py);/* pxmy mxmy */
line(mousex,mousey,px,mousey);
line(mousex,mousey,mousex,py);
showmouseptr();

if(buttclicked()!=1)break;
wheremouse(&mousex,&mousey);
if(over(40,50,MAX_X-60,MAX_Y-65)==0)
while(over(40,50,MAX_X-60,MAX_Y-65)==0);
if(buttclicked()!=1)break;

hidemouseptr();
line(px,py,px,mousey);
line(px,py,mousex,py);
line(mousex,mousey,px,mousey);
line(mousex,mousey,mousex,py);
showmouseptr();
}
hidemouseptr();
setcolor(WHITE);

setwritemode(COPY_PUT);
setcolor(Current_Color);
ex= (px+mousex)/2;
ey=(py+mousey)/2 ;
ellipse( ex , ey , 0,360, abs((px-mousex)/2) ,abs((py-mousey)/2));
r=abs( (py-mousey)/2);
for(i=4;i<= r;i+=5)
{
ellipse( ex , ey , 0,360, abs((px-mousex)/2) ,i);
}
r= abs( (px-mousex)/2);
for(i=4;i<=r;i+=5)
{
ellipse( ex , ey , 0,360, i,abs((py-mousey)/2));
}
showmouseptr();
}
}

int over(int x,int y,int w,int h)
{
int x1,y1;

x1=x+w;
y1=y+h;
wheremouse(&mousex,&mousey);

if( (mousex>x) && (mousex<x1) && (mousey>y) && (mousey <y1) )
return 1;
else
return 0;
}

void clip()
{
int i,j;
if(!marked) return;

unmark();
for(j=MIN_Y+2;j<=MAX_Y-2;++j)
{
for(i=MIN_X+2;i<=MAX_X-2;++i)
{
if( (i>=marker.left&&i<=marker.right) &&( j>=marker.top && j<=marker.bottom ) )
{
}
else
putpixel(i,j,WHITE);
}
}
}


void mark()
{
int color=15-BLACK;
int x,y;

if(marked)
unmark();

setcolor(color);
setwritemode(XOR_PUT);

x=mousex;
y=mousey;
prevx=x;
prevy=y;
setlinestyle(DOTTED_LINE,1,1);
while(LeftButtonPressed)
{ getxy();
if(mousex!=prevx||mousey!=prevy)
{
disp_coord();
rectangle(x,y,prevx,prevy);
rectangle(x,y,mousex,mousey);
}
}
setlinestyle(SOLID_LINE,1,1);

if(x<mousex)
{
marker.left=x;
marker.right=mousex;
if(y<mousey)
{
marker.top=y;
marker.bottom=mousey;
}
else
{
marker.top=mousey;
marker.bottom=y;
}
}
else
{
marker.left=mousex;
marker.right=x;
if(y<mousey)
{
marker.top=y;
marker.bottom=mousey;
}
else
{
marker.top=mousey;
marker.bottom=y;
}
}
marked=1;
setwritemode(COPY_PUT);
}

void unmark()
{
int color=15-BLACK;
setcolor(color);
setwritemode(XOR_PUT);
setlinestyle(DOTTED_LINE,1,1);
rectangle(marker.left,marker.top,marker.right,marker.bottom);
setlinestyle(SOLID_LINE,1,1);
setwritemode(COPY_PUT);
marked=0;

}

void extclip()
{
if(marked)
{
unmark();
setfillstyle(SOLID_FILL,WHITE);
bar(marker.left,marker.top,marker.right,marker.bottom);
}
}

void flip()
{
int col;
int y1,y2;
int color1,color2;

for(col=MIN_X+2;col<=MAX_X-2;++col)
{
y1=MIN_Y+2;
y2=MAX_Y-2;
while(y1<y2)
{
color1=getpixel(col,y1);
color2=getpixel(col,y2);
putpixel(col,y2,color1);
putpixel(col,y1,color2);
y1++;
y2--;
}
}
}

void mirror()
{
int row;
int x1,x2;
int color1,color2;

for(row=MIN_Y+2;row<=MAX_Y-2;++row)
{
x1=MIN_X+2;
x2=MAX_X-2;
while(x1<x2)
{
color1=getpixel(x1,row);
color2=getpixel(x2,row);
putpixel(x2,row,color1);
putpixel(x1,row,color2);
x1++;
x2--;
}
}
}

void Diagram()
{
restrictmouseptr(MIN_X+2,MIN_Y+2,MAX_X-2,MAX_Y-2);
hidemouseptr();
switch(Current_Button)
{
case 1: erase(); break;
case 2: drawline(); break;
case 3: drawrectangle();break;
case 4: drawcircle();break;
case 5: drawspiral();break;
case 6: freehand(); break;
case 7: Cube(); break;
case 8: Bucket(); break;
case 9: drawellipse();break;
case 10: mark(); break;
case 11: clip(); break;
case 12: drawtext(); break;
case 13: sphere(); break;
case 14: extclip(); break;
case 15: translate(); break;
case 16: rotate(); break;
case 17: scale(); break;
case 18: dark(); break;
case 19: light(); break;
case 20: invert(); break;
case 21: blackwhite(); break;

}
showmouseptr();
restrictmouseptr(0,0,639,479);
}

/* This is for initialization of the whole layout */
void init()
{
int x1=5,y1=35,x2=38,y2=MAX_Y+28,ywidth=30,xwidth=30;
int butt=1,i,j;
init_button(butt,x1,y1,xwidth,ywidth,"Eraser",0);
draw_button_border(butt);
Erase_ico(x1,y1);
butt++;

init_button(butt,x2,y1,xwidth,ywidth,"Line",0);
draw_button_border(butt);
Line_ico(x2,y1);
butt++;


y1=y1+ywidth;

init_button(butt,x1,y1,xwidth,ywidth,"Rectangle",0);
draw_button_border(butt);
Rectangle_ico(x1,y1);
butt++;


init_button(butt,x2,y1,xwidth,ywidth,"Circle",0);
draw_button_border(butt);
Circle_ico(x2,y1);
butt++;

y1=y1+ywidth;

init_button(butt,x1,y1,xwidth,ywidth,"Spiral",0);
draw_button_border(butt);
Spiral_ico(x1,y1);
butt++;

init_button(butt,x2,y1,xwidth,ywidth,"Pencil",0);
draw_button_border(butt);
Brush_ico(x2,y1);
butt++;
y1=y1+ywidth;

init_button(butt,x1,y1,xwidth,ywidth,"Cuboid",0);
draw_button_border(butt);
Cube_ico(x1,y1);
butt++;

init_button(butt,x2,y1,xwidth,ywidth,"Fill",0);
draw_button_border(butt);
Bucket_ico(x2,y1);
butt++;
y1=y1+ywidth;

init_button(butt,x1,y1,xwidth,ywidth,"Ellipse Drawing Tool",0);
draw_button_border(butt);
Ellipse_ico(x1,y1);
butt++;

init_button(butt,x2,y1,xwidth,ywidth,"Selection Tool",0);
draw_button_border(butt);
Mark_ico(x2,y1);
butt++;
y1=y1+ywidth;


init_button(butt,x1,y1,xwidth,ywidth,"Clipping (Works with Mark)",0);
draw_button_border(butt);
Clip_ico(x1,y1);
butt++;

init_button(butt,x2,y1,xwidth,ywidth,"Text",0);
draw_button_border(butt);
//printf("%d",butt);
Alphabet_ico(x2,y1);
butt++;

y1=y1+ywidth;

init_button(butt,x1,y1,xwidth,ywidth,"3D Ellipse Drawing Tool",0);
draw_button_border(butt);
Sphere_ico(x1,y1);
butt++;

init_button(butt,x2,y1,xwidth,ywidth,"Exterior Clipping(Works with Mark)",0);
draw_button_border(butt);
Del_ico(x2,y1);
butt++;


init_button(butt,260,414,50,20,"Translation(Works with Mark)",0);
draw_button_border(butt);
outtextxy(262,418,"Trans");
butt++;

init_button(butt,320,414,50,20,"Rotation(Works with Mark)",0);
draw_button_border(butt);
outtextxy(322,418,"Rotat");
butt++;

init_button(butt,380,414,50,20,"Scaling(Works with Mark)",0);
draw_button_border(butt);
outtextxy(382,418,"Scale");
butt++;

init_button(butt,260,436,50,20,"Darkening Contrast Effect",0);
draw_button_border(butt);
outtextxy(262,438,"Darken");
butt++;

init_button(butt,320,436,50,20,"Brighten up the Image",0);
draw_button_border(butt);
outtextxy(322,438,"Light");
butt++;

init_button(butt,380,436,50,20,"Invert the Colours",0);
draw_button_border(butt);
outtextxy(382,438,"Invert");
butt++;

init_button(butt,440,414,50,20,"Convert to Black & White",0);
draw_button_border(butt);
outtextxy(442,418,"B & W");
butt++;

x1=MIN_X+5;
init_button(butt,x1,17,80,20,"FILE handling options",0);
draw_button_border(butt);
outtextxy(x1+15,23,"FILE");
x1=x1+83;
butt++;

init_button(butt,x1,17,80,20,"EDITING options",0);
//printf("%d",butt);
draw_button_border(butt);
outtextxy(x1+15,23,"EDIT");
x1=x1+83;
butt++;

init_button(butt,x1,17,80,20,"FORMATING tools",0);
draw_button_border(butt);
outtextxy(x1+15,23,"FORMAT");
x1=x1+83;
butt++;

init_button(butt,x1,17,80,20,"NEED HELP? click on this",0);
draw_button_border(butt);
outtextxy(x1+15,23,"HELP");
x1=x1+80;
butt++;

butt=0;
x1=MIN_X+8;
y1=MAX_Y+9;
xwidth=19;ywidth=15;
for(i=0;i<8;i++)
{
init_color_button(butt,x1,y1,xwidth,ywidth,1);
draw_color_button_border(butt,1);
butt++;

init_color_button(butt,x1,y2,xwidth,ywidth,1);
draw_color_button_border(butt,1);
butt++;

x1=x1+xwidth;

}

butt=0;
x1=25;
y1=290;
for(i=0;i<6;i++)
{
x2=x1+xwidth+2;
init_color_button(butt,x1,y1,xwidth,ywidth,0);
draw_color_button_border(butt,0);
butt++;

init_color_button(butt,x2,y1,xwidth,ywidth,0);
draw_color_button_border(butt,0);
butt++;

y1=y1+ywidth+5;

}
/* This is for the small Window which shows the color */
setfillstyle(Current_Pattern,Current_Color);
bar(20,MAX_Y+7,65,MAX_Y+7+35);
setcolor(BLACK);
rectangle(20,MAX_Y+7,65,MAX_Y+7+35);
setcolor(Current_Color);
}



void init_color_button(int color,int xmin,int ymin,int xwidth,int ywidth,int colflag)
{
int xgap=4;
if (colflag)
{
colorbuttons[color].xmin=xmin;
colorbuttons[color].xmax=xmin+xwidth-xgap;
colorbuttons[color].ymin=ymin;
colorbuttons[color].ymax=ymin+ywidth;
colorbuttons[color].color=color;
colorbuttons[color].colflag=colflag;
}
else
{
colorbuttons[color+16].xmin=xmin;
colorbuttons[color+16].xmax=xmin+xwidth-xgap;
colorbuttons[color+16].ymin=ymin;
colorbuttons[color+16].ymax=ymin+ywidth;
colorbuttons[color+16].color=color;
colorbuttons[color+16].colflag=colflag;
}
}

void draw_color_button_border(int no,int colflag)
{
int color=getcolor();
setcolor(BLACK);
if (colflag)
{
line(colorbuttons[no].xmin,colorbuttons[no].ymin,colorbuttons[no].xmax,colorbuttons[no].ymin);
line(colorbuttons[no].xmin,colorbuttons[no].ymin,colorbuttons[no].xmin,colorbuttons[no].ymax);
line(colorbuttons[no].xmax,colorbuttons[no].ymax,colorbuttons[no].xmax,colorbuttons[no].ymin);
line(colorbuttons[no].xmax,colorbuttons[no].ymax,colorbuttons[no].xmin,colorbuttons[no].ymax);
setfillstyle(1,no);
floodfill(colorbuttons[no].xmin+1,colorbuttons[no].ymin+1,BLACK);
}
else
{
line(colorbuttons[no+16].xmin,colorbuttons[no+16].ymin,colorbuttons[no+16].xmax,colorbuttons[no+16].ymin);
line(colorbuttons[no+16].xmin,colorbuttons[no+16].ymin,colorbuttons[no+16].xmin,colorbuttons[no+16].ymax);
line(colorbuttons[no+16].xmax,colorbuttons[no+16].ymax,colorbuttons[no+16].xmax,colorbuttons[no+16].ymin);
line(colorbuttons[no+16].xmax,colorbuttons[no+16].ymax,colorbuttons[no+16].xmin,colorbuttons[no+16].ymax);
setfillstyle(no,WHITE);
floodfill(colorbuttons[no+16].xmin+1,colorbuttons[no+16].ymin+1,BLACK);
}
setcolor(color);
}


void init_button(int no,int xmin,int ymin,int xwidth,int ywidth,char* desc,int popno)
{
int ygap=4;
buttons[no].xmin=xmin;
buttons[no].ymin=ymin;
buttons[no].xmax=xmin+xwidth;
buttons[no].ymax=ymin+ywidth-ygap;
buttons[no].desc=(char *) malloc(strlen(desc)+1);
if(buttons[no].desc==NULL)
{
cleardevice();
printf("\n No MEMORY ");
}
strcpy(buttons[no].desc,desc);
buttons[no].popup = popno;
}


void draw_button_border(int no)
{
int color=getcolor();
hidemouseptr();
setcolor(LIGHTGREEN);
line(buttons[no].xmin,buttons[no].ymin,buttons[no].xmax,buttons[no].ymin);
line(buttons[no].xmin,buttons[no].ymin,buttons[no].xmin,buttons[no].ymax);
setcolor(BLACK);
line(buttons[no].xmax,buttons[no].ymax,buttons[no].xmax,buttons[no].ymin);
line(buttons[no].xmax,buttons[no].ymax,buttons[no].xmin,buttons[no].ymax);
setcolor(color);
showmouseptr();
}

void undraw_button_border(int no)
{
int i,j;
int color=getcolor();
hidemouseptr();
setcolor(BLACK);
line(buttons[no].xmin,buttons[no].ymin,buttons[no].xmax,buttons[no].ymin);
line(buttons[no].xmin,buttons[no].ymin,buttons[no].xmin,buttons[no].ymax);
setcolor(LIGHTGRAY);
line(buttons[no].xmax,buttons[no].ymax,buttons[no].xmax,buttons[no].ymin);
line(buttons[no].xmax,buttons[no].ymax,buttons[no].xmin,buttons[no].ymax);
setcolor(color);
showmouseptr();
}

void Line_ico(int x1, int y1)
{
line(8+x1, 5+y1, 22+x1, 19+y1);
}

void Rectangle_ico(int x1, int y1)
{
rectangle(8+x1, 5+y1, 22+x1, 19+y1);
}

void Circle_ico(int x1, int y1)
{
circle(15+x1, 12+y1, 8);
}

void Spiral_ico(int x1, int y1)
{
int xrad=3,yrad=1;
int i;
x1=15+x1;
y1=14+y1;
for( i = 1; i <=4; ++i )
{
ellipse( x1, y1, 90, 270, xrad, yrad );
xrad += 1;
yrad += 1;
y1 -= 1;
ellipse( x1, y1, 270, 90, xrad, yrad );
xrad += 1;
yrad += 1;
y1 += 1;
}
}

void Brush_ico(int x1, int y1)
{
setcolor(BLACK);
setlinestyle(0, 1, 3);
line(19+x1, 21+y1, 10+x1, 9+y1);
setlinestyle(0, 1, 1);
line(11+x1, 9+y1, 11+x1, 6+y1);
line(11+x1, 6+y1, 6+x1, 4+y1);
line(6+x1, 4+y1, 7+x1, 9+y1);
line(7+x1, 9+y1, 11+x1, 9+y1);
}

void Fill_ico(int x1, int y1)
{
setlinestyle(0, 1, 1);
setcolor(BLACK);
line(10+x1, 11+y1, 16+x1, 19+y1);
line(16+x1, 19+y1, 25+x1, 12+y1);
line(25+x1, 12+y1, 20+x1, 5+y1);

line(10+x1, 11+y1, 24+x1, 11+y1);
setfillstyle(1, RED);
floodfill( 12+x1, 12+y1, BLACK);
setcolor(RED);
line(10+x1, 11+y1, 8+x1, 14+y1);
line(8+x1, 14+y1, 8+x1, 16+y1);
}

void Cube_ico(int x, int y)
{
rectangle(8+x, 5+y, 24+x, 17+y);
rectangle(5+x, 9+y, 21+x, 21+y);
line(5+x, 9+y, 8+x, 5+y);
line(21+x, 21+y, 24+x, 17+y);
line(21+x, 9+y, 24+x, 5+y);
line(5+x, 21+y, 8+x, 17+y);
}

void Erase_ico(int x1, int y1)
{
setlinestyle(0, 1, 1);
setcolor(BLACK);
line(14+x1, 20+y1, 25+x1, 7+y1);
line(25+x1, 7+y1, 23+x1, 4+y1);
line(23+x1, 4+y1, 12+x1, 17+y1);
line(12+x1, 17+y1, 14+x1, 20+y1);

line(14+x1, 20+y1, 5+x1, 20+y1);
line(5+x1, 20+y1, 5+x1, 17+y1);
line(5+x1, 17+y1, 12+x1, 17+y1);

line(5+x1, 17+y1, 16+x1, 4+y1);
line(16+x1, 4+y1, 23+x1, 4+y1);

setfillstyle(1, WHITE);
floodfill(14+x1, 18+y1, BLACK);
setfillstyle(1, WHITE);
floodfill(16+x1, 5+y1, BLACK);
}

void Clip_ico(int x1, int y1)
{
setlinestyle(0, 1, 1);
setcolor(BLACK);
rectangle(5+x1, 5+y1, 25+x1, 19+y1);
setfillstyle(1, WHITE);
floodfill(15+x1, 12+y1, BLACK);
setfillstyle(1,BLACK);
bar(12+x1, 10+y1, 23+x1, 17+y1);
}

void Del_ico(int x1, int y1)
{
setlinestyle(0, 1, 1);
setcolor(WHITE);
rectangle(5+x1, 5+y1, 25+x1, 19+y1);
setfillstyle(1, BLACK);
floodfill(15+x1, 12+y1, WHITE);
setfillstyle(1,WHITE);
bar(12+x1, 10+y1, 23+x1, 17+y1);
}

void Bucket_ico(int x, int y)
{
setlinestyle(0, 1, 1);
setcolor(BLACK);
line(7+x, 8+y, 11+x, 20+y);
line(11+x, 20+y, 21+x, 16+y);
line(21+x, 16+y, 17+x, 4+y);
line(7+x, 8+y, 17+x, 4+y);
line(17+x, 4+y, 7+x, 8+y);

line(3+x, 12+y, 7+x, 8+y);
line(3+x, 12+y, 5+x, 15+y);
line(5+x, 15+y, 7+x, 8+y);

setfillstyle(1, BLUE);
floodfill(10+x, 9+y, BLACK);

setfillstyle(1, YELLOW);
floodfill(5+x, 13+y, BLACK);


}

void Ellipse_ico(int x1,int y1)
{
ellipse(15+x1, 13+y1, 0, 360, 8, 6);
}

void Alphabet_ico(int x, int y)
{
setcolor(BLACK);
setlinestyle(0, 1, 3);
line(8+x, 20+y, 18+x, 4+y);
line(18+x, 4+y, 18+x, 20+y);
setlinestyle(0, 1, 1);
line(12+x, 14+y, 19+x, 14+y);
line(6+x, 20+y, 12+x, 20+y);
line(15+x, 20+y, 21+x, 20+y);
}

void Mark_ico(int x1, int y1)
{
setlinestyle(0, 1, 1);
setcolor(BLACK);
setlinestyle(3, 1, 1);
rectangle(5+x1, 5+y1, 25+x1, 19+y1);
setlinestyle(0, 1, 1);
}

void Sphere_ico(int x1, int y1)
{
setlinestyle(0, 1, 1);
setcolor(BLACK);
circle(x1+15,y1+13,8);
ellipse(x1+15,y1+13,0,360,4,8);
ellipse(x1+15,y1+13,0,360,8,4);
}

void start_up()
{
setfillstyle(1,CYAN);

floodfill(200, 200, 1);

/* FOR
MAIN WINDOW */
setcolor(15);
line(0, 0, 639, 0);
line(0, 0+1, 639-1, 0+1);
line(0, 0, 0, 479-1);
line(0+1, 0, 0+1, 479-2);
setcolor(8);
line(639, 0+1, 639, 479);
line(639-1, 0+2, 639-1, 479-1);
line(639, 479, 0, 479);
line(639, 479-1, 0+1, 479-1);

/* for drawing window */
setcolor(WHITE);
rectangle(MIN_X, MIN_Y, MAX_X, MAX_Y);
setfillstyle(1, WHITE);
floodfill(300, 300, WHITE);

setcolor(8);
line(MIN_X, MIN_Y, MAX_X, MIN_Y);
line(MIN_X, MIN_Y+1, MAX_X-1, MIN_Y+1);
line(MIN_X, MIN_Y, MIN_X, MAX_Y-1);
line(MIN_X+1, MIN_Y, MIN_X+1, MAX_Y-2);
setcolor(8);
line(MAX_X, MIN_Y+1, MAX_X, MAX_Y);
line(MAX_X-1, MIN_Y+2, MAX_X-1, MAX_Y-1);
line(MAX_X, MAX_Y, MIN_X, MAX_Y);
line(MAX_X, MAX_Y-1, MIN_X+1, MAX_Y-1);

/* for status bar */
setcolor(8);
line(10, 460, 629, 460);
line(10, 460, 10, 479 - 5-1);
setcolor(15);
line(629, 460 , 629, 479 - 5);
line(629, 479 - 5, 10, 479 - 5);

/*/ For color*/
setcolor(15);
line(MIN_X, MAX_Y+4, 251, MAX_Y+4);
line(MIN_X, MAX_Y+4, MIN_X,MAX_Y+47);
setcolor(0);
line(251, MAX_Y+47 , MIN_X, MAX_Y+47);
line(251, MAX_Y+47, 251, MAX_Y+4);

/*/ For the Menu bar */
setcolor(15);
line(MIN_X,15,MAX_X,15);
line(MIN_X,15,MIN_X,34);
setcolor(0);
line(MAX_X,34,MAX_X,15);
line(MAX_X,34,MIN_X,34);


/* For the pattern pallete */
setcolor(15);
line(15,285,15,410);
line(15,285,70,285);
setcolor(0);
line(70,410,70,285);
line(70,410,15,410);

}

void disp_filename()
{
char name[60];
int xpos;
setfillstyle(SOLID_FILL,LIGHTBLUE);
bar(3,5,630,15);
strcpy(name,"MY PAINTING CANVAS- ");
strcat(name,FileName);
xpos=200;
setcolor(LIGHTRED);
outtextxy(xpos,8,name);
setfillstyle(SOLID_FILL,BLUE);
bar(614,6,628,17);
rectangle(617,6,629,17);
setcolor(WHITE);
outtextxy(620,8,"X");
}

void highlight(int x1,int y1,int x2,int y2,int bgcolor,int flcolor)
{
int i,j;
hidemouseptr();
for(i=x1;i<x2;i++)
for(j=y1;j<y2;j++)
{
if(getpixel(i,j)==bgcolor)
putpixel(i,j,flcolor);
}
showmouseptr();
}
void showeditmenu(int x1,int y1,int xwidth,int ywidth,int xtemp,int ytemp)
{
//undraw_button_border(15);
int area,button,x,y;
char* buff1;
hidemouseptr();
area=imagesize(x1,y1+ywidth,x1+xwidth,y1+ywidth);
buff1=(char*)malloc(area);
getimage(x1,y1+ywidth,x1+xwidth,y1+ywidth*5,buff1);
//setcolor(RED);
setfillstyle(1,3);
bar(x1,y1+ywidth,x1+xwidth,y1+ywidth*5);
setcolor(RED);
rectangle(x1,y1+ywidth,x1+xwidth,y1+ywidth*5);

//floodfill(x1+1,y1+ywidth+1,RED);
rectangle(x1,y1+ywidth,x1+xwidth,y1+2*ywidth);
outtextxy(x1+25,y1+ywidth+5,"cut");
rectangle(x1,y1+ywidth*2,x1+xwidth,y1+3*ywidth);
outtextxy(x1+25,y1+ywidth*2+5,"copy");
rectangle(x1,y1+ywidth*3,x1+xwidth,y1+4*ywidth);
outtextxy(x1+25,y1+ywidth*3+5,"paste");
rectangle(x1,y1+ywidth*4,x1+xwidth,y1+5*ywidth);
outtextxy(x1+25,y1+ywidth*4+5,"clear");
showmouseptr();
getmousepos(&button,&x,&y);
int fileflag=0;

int tempx=0;
int tempy=0;
while(!(button==1 && (x!=xtemp || y!=ytemp)))
{
getmousepos(&button,&x,&y);
if(x>x1 && x<x1+xwidth && y>y1+ywidth && y<y1+5*ywidth )
{

if(y<y1+2*ywidth)
{
if(fileflag!=1)
{

ShowStatus("warning: do not cut large areas");
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+ywidth,x1+xwidth,y1+2*ywidth,CYAN,BLUE);
fileflag=1;
}
}
else if(y<y1+3*ywidth)
{
if(fileflag!=2)
{
ShowStatus("warning: do not copy large areas");
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);

highlight(x1,y1+2*ywidth,x1+xwidth,y1+3*ywidth,CYAN,BLUE);
fileflag=2;
}
}
else if(y<y1+4*ywidth)
{
if(fileflag!=3)
{
ShowStatus("paste the cut/copied part of the image");
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);

highlight(x1,y1+3*ywidth,x1+xwidth,y1+4*ywidth,CYAN,BLUE);
fileflag=3;
}
}
else if(y<y1+5*ywidth)
{
if(fileflag!=4)
{
ShowStatus("clear the canvas");
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);


highlight(x1,y1+4*ywidth,x1+xwidth,y1+5*ywidth,CYAN,BLUE);
fileflag=4;
}
}

}


}hidemouseptr();
putimage(x1,y1+ywidth,buff1,COPY_PUT);
//draw_button_border(15);
showmouseptr();
ShowStatus(" ");

if(!(x<x1||y<y1+ywidth||x>x1+xwidth||y>y1+ywidth*5))
{

switch(fileflag)
{
case 1:
cut();//call cut function
break;
case 2:

copy();//call copy function
break;
case 3:
callpaste();//call paste function
break;
case 4:

setfillstyle(SOLID_FILL,WHITE);
hidemouseptr();
bar(MIN_X,MIN_Y,MAX_X,MAX_Y); //call clear function
showmouseptr();
break;

}
//delay(500);
showmouseptr();
}

//delay(300);

free(buff1);

}

void showfilemenu(int x1,int y1,int xwidth,int ywidth,int xtemp,int ytemp)
{
//undraw_button_border(14);
int area,button,x,y;
char* buff1;
hidemouseptr();
area=imagesize(x1,y1+ywidth,x1+xwidth,y1+ywidth);
buff1=(char*)malloc(area);
getimage(x1,y1+ywidth,x1+xwidth,y1+ywidth*5,buff1);
setfillstyle(1,3);
bar(x1,y1+ywidth,x1+xwidth,y1+ywidth*5);
setcolor(RED);
rectangle(x1,y1+ywidth,x1+xwidth,y1+ywidth*5);
rectangle(x1,y1+ywidth,x1+xwidth,y1+2*ywidth);
outtextxy(x1+25,y1+ywidth+5,"New");
rectangle(x1,y1+ywidth*2,x1+xwidth,y1+3*ywidth);
outtextxy(x1+25,y1+ywidth*2+5,"Open");
rectangle(x1,y1+ywidth*3,x1+xwidth,y1+4*ywidth);
outtextxy(x1+25,y1+ywidth*3+5,"Save");
rectangle(x1,y1+ywidth*4,x1+xwidth,y1+5*ywidth);
outtextxy(x1+25,y1+ywidth*4+5,"Quit");
showmouseptr();
getmousepos(&button,&x,&y);
int fileflag=0;

int tempx=0;
int tempy=0;
while(!(button==1 && (x!=xtemp || y!=ytemp)))
{
getmousepos(&button,&x,&y);
if(x>x1 && x<x1+xwidth && y>y1+ywidth && y<y1+5*ywidth )
{

if(y<y1+2*ywidth)
{
if(fileflag!=1)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+ywidth,x1+xwidth,y1+2*ywidth,CYAN,BLUE);
fileflag=1;
}
}
else if(y<y1+3*ywidth)
{
if(fileflag!=2)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);

highlight(x1,y1+2*ywidth,x1+xwidth,y1+3*ywidth,CYAN,BLUE);
fileflag=2;
}
}
else if(y<y1+4*ywidth)
{
if(fileflag!=3)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);

highlight(x1,y1+3*ywidth,x1+xwidth,y1+4*ywidth,CYAN,BLUE);
fileflag=3;
}
}
else if(y<y1+5*ywidth)
{
if(fileflag!=4)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);


highlight(x1,y1+4*ywidth,x1+xwidth,y1+5*ywidth,CYAN,BLUE);
fileflag=4;
}
}

}

}
hidemouseptr();
putimage(x1,y1+ywidth,buff1,COPY_PUT);
//draw_button_border(14);
showmouseptr();
if(!(x<x1||y<y1+ywidth||x>x1+xwidth||y>y1+ywidth*5))
{
switch(fileflag)
{
case 1:
new_file();
//call new function
break;
case 2:
load();
//call open function
break;
case 3:
save();
//call save function
break;
case 4:
quit();
break;

}
}



free(buff1);
}


void showformatmenu(int x1,int y1,int xwidth,int ywidth,int xtemp,int ytemp)
{
//undraw_button_border(16);
int area,button,x,y;
char* buff1;
hidemouseptr();
area=imagesize(x1,y1+ywidth,x1+xwidth*3,y1+ywidth);
buff1=(char*)malloc(area);
getimage(x1,y1+ywidth,x1+xwidth,y1+ywidth*3,buff1);
setfillstyle(1,3);
bar(x1,y1+ywidth,x1+xwidth,y1+ywidth*3);
setcolor(RED);
rectangle(x1,y1+ywidth,x1+xwidth,y1+ywidth*3);
rectangle(x1,y1+ywidth,x1+xwidth,y1+2*ywidth);
outtextxy(x1+5,y1+ywidth+5,"Flip(hor)");
rectangle(x1,y1+ywidth*2,x1+xwidth,y1+3*ywidth);
outtextxy(x1+5,y1+ywidth*2+5,"Flip(ver)");


showmouseptr();
getmousepos(&button,&x,&y);
int fileflag=0;

int tempx=0;
int tempy=0;
while(!(button==1 && (x!=xtemp || y!=ytemp)))
{
getmousepos(&button,&x,&y);
if(x>x1 && x<x1+xwidth && y>y1+ywidth && y<y1+3*ywidth )
{

if(y<y1+2*ywidth)
{
if(fileflag!=1)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+ywidth,x1+xwidth,y1+2*ywidth,CYAN,BLUE);
fileflag=1;
}
}
else if(y<y1+3*ywidth)
{
if(fileflag!=2)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);

highlight(x1,y1+2*ywidth,x1+xwidth,y1+3*ywidth,CYAN,BLUE);
fileflag=2;
}
}
}

}
hidemouseptr();
putimage(x1,y1+ywidth,buff1,COPY_PUT);
showmouseptr();
//draw_button_border(16);
if(!(x<x1||y<y1+ywidth||x>x1+xwidth||y>y1+ywidth*3))
{
delay(1000);
hidemouseptr();
switch(fileflag)
{
case 1:
//call fliphorizontally function
mirror();
break;
case 2:
//call flipvertically function
flip();
break;
}
showmouseptr();

}
free(buff1);

}

void showhelpmenu(int x1,int y1,int xwidth,int ywidth,int xtemp,int ytemp)
{
//undraw_button_border(17);
int area,button,x,y;
char* buff1;
hidemouseptr();
area=imagesize(x1,y1+ywidth,x1+xwidth,y1+ywidth);
buff1=(char*)malloc(area);
getimage(x1,y1+ywidth,x1+xwidth,y1+ywidth*3,buff1);
setfillstyle(1,3);
bar(x1,y1+ywidth,x1+xwidth,y1+ywidth*3);
setcolor(RED);
rectangle(x1,y1+ywidth,x1+xwidth,y1+ywidth*3);
rectangle(x1,y1+ywidth,x1+xwidth,y1+2*ywidth);
outtextxy(x1+2,y1+ywidth+5,"About");
rectangle(x1,y1+ywidth*2,x1+xwidth,y1+3*ywidth);
outtextxy(x1+1,y1+ywidth*2+5,"Topics");

//rectangle(x1,y1+ywidth*3,x1+xwidth,y1+4*ywidth);
//outtextxy(x1+25,y1+ywidth*3+5,"Save");
//rectangle(x1,y1+ywidth*4,x1+xwidth,y1+5*ywidth);
//outtextxy(x1+25,y1+ywidth*4+5,"Quit");

showmouseptr();
getmousepos(&button,&x,&y);
int fileflag=0;

int tempx=0;
int tempy=0;
while(!(button==1 && (x!=xtemp || y!=ytemp)))
{
getmousepos(&button,&x,&y);
if(x>x1 && x<x1+xwidth && y>y1+ywidth && y<y1+3*ywidth )
{

if(y<y1+2*ywidth)
{
if(fileflag!=1)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);
highlight(x1,y1+ywidth,x1+xwidth,y1+2*ywidth,CYAN,BLUE);
fileflag=1;
}
}
else if(y<y1+3*ywidth)
{
if(fileflag!=2)
{
highlight(x1,y1+fileflag*ywidth,x1+xwidth,y1+(fileflag+1)*ywidth,BLUE,CYAN);

highlight(x1,y1+2*ywidth,x1+xwidth,y1+3*ywidth,CYAN,BLUE);
fileflag=2;
}
}


}

}
hidemouseptr();
putimage(x1,y1+ywidth,buff1,COPY_PUT);
//draw_button_border(17);
showmouseptr();
if(!(x<x1||y<y1+ywidth||x>x1+xwidth||y>y1+ywidth*3))
{
switch(fileflag)
{
case 1:
about();
//call about function
break;
case 2:
topic();
//call help function
break;
}
}



free(buff1);
}

void disp_coord()
{
char xy[25];
int color;
if(prevx!=mousex||prevy!=mousey)
if( (mousex>MIN_X+1)&&(mousex<MAX_X-1)&&(mousey>MIN_Y+1)&&(mousey<MAX_Y-1))
{
sprintf(xy," x:%d y:%d",mousex-MIN_X-2,mousey-MIN_Y-2);
color=getcolor();
setcolor(CYAN);
outtextxy(520,22,"&#1594;&#1594;&#1594;&#1594;&#1594;&#1594;&#1594;&#1594;&#1594;&#1594;&#1594;&#1594;" );/* ALT 219*/
//outtextxy(475,464,"Hello");
setcolor(BLACK);
outtextxy(520,22,xy);
setcolor(color);
}

}

/*void getxy()
{
union REGS regs;
regs.x.ax=3;
int86(0x33,&regs,&regs);

prevx=mousex;
prevy=mousey;
mousex=regs.x.cx;
mousey=regs.x.dx;
} */


int check_if_color()
{
int i=0;
for(i=0;i<MAX_COLPAT;i++)
{
if(check_mouse_on(colorbuttons[i].xmin,colorbuttons[i].ymin,colorbuttons[i].xmax,colorbuttons[i].ymax))
{
if(colorbuttons[i].colflag)
{
Current_Color=colorbuttons[i].color;
}
else
Current_Pattern=colorbuttons[i].color;
if (Current_Pattern==EMPTY_FILL)
setfillstyle(SOLID_FILL,Current_Color);
else
setfillstyle(Current_Pattern,Current_Color);
bar(20,MAX_Y+7,65,MAX_Y+7+35);
setcolor(BLACK);
rectangle(20,MAX_Y+7,65,MAX_Y+7+35);
setcolor(Current_Color);

if(precolflag==0)
ShowStatus("Select the Color & Pattern You Want");
precolflag=1;
return 1;
}
}
precolflag=0;
return 0;

}

int check_mouse_on(int minx,int miny,int maxx,int maxy)
{
if(mousex<minx)
return 0;
if(mousex>maxx)
return 0;
if(mousey<miny)
return 0;
if(mousey>maxy)
return 0;

return 1;
}


void quit()
{

setcolor(RED);
end_about();
exit(0);
}

int check_if_button_pressed()
{
int ret_value=0;
int i,k;
char ch;
int pop;


for(i=1;i<=MAX_BUTTONS;++i)
{
if((check_mouse_on(buttons[i].xmin,buttons[i].ymin,buttons[i].xmax,buttons[i].ymax)))
{
if(Current_Button!=i)
{
//if(prevx!=)
if(i!=previ)
{
ShowStatus(buttons[i].desc);
previ=i;
}
if(LeftButtonPressed)
{
Prev_Button=Current_Button;
Current_Button=i;
undraw_button_border(Current_Button);
draw_button_border(Prev_Button);
ret_value=i; break;
}
}
}

}
return ret_value;
}

void check_if_exit()
{
int i,j;
if(check_mouse_on(617,6,629,17))
{
{
for(i=618;i<629;i++)
{
for(j=7;j<17;j++)
{
if(getpixel(i,j)==BLUE)
putpixel(i,j,RED);
}
}
}
if(LeftButtonPressed)
{
flushall();
closegraph();
exit(0);
}
}
}

void ClearStatus()
{

static int first_time;
static char text[59];
int i;

setcolor(CYAN);
if(!first_time)
{
strcpy(text,"");
for(i=0;i<58;++i)
strcat(text,"&#1594;");
text[58]='\0';
first_time=1;
}
outtextxy(12,464,text);

}
/*
void showstatus(int x,int y)
{
outtextxy(20,465,"write function here");
}
*/
void translate()
{
int left,right,bottom,top;
int diffx,diffy;
int color=15-BLACK;
char* image;
int size;


if(!marked) return;
if(check_mouse_on(marker.left,marker.top,marker.right,marker.bottom))
{
setwritemode(XOR_PUT);
setcolor(color);
setlinestyle(DOTTED_LINE,1,1);

left=marker.left;
right=marker.right;
top=marker.top;
bottom=marker.bottom;

while(LeftButtonPressed)
{
rectangle(left,top,right,bottom);
getxy();
diffx=prevx-mousex;
diffy=prevy-mousey;
left=left-diffx;
right=right-diffx;
bottom=bottom-diffy;
top=top-diffy;
if( (left<MIN_X+2)||(right>MAX_X-2)||(top<MIN_Y+2)||(bottom>MAX_Y-2) )
{
left=left+diffx;
right=right+diffx;
bottom=bottom+diffy;
top=top+diffy;
}
rectangle(left,top,right,bottom);
}

marked=0;
setwritemode(COPY_PUT);
size=imagesize(marker.left,marker.top,marker.right,marker.bottom);
if(size!=-1)
{
image=(char*)malloc(size);
if(image!=NULL)
{
getimage(marker.left,marker.top,marker.right,marker.bottom,image);
setfillstyle(SOLID_FILL,WHITE);
bar(marker.left,marker.top,marker.right,marker.bottom);
putimage(left,top,image,COPY_PUT);
free(image);
}
else
{
ShowStatus(" No Memory! ");
delay(1000);
ClearStatus();
}
}
else
{
ShowStatus(" No Memory! ");
delay(1000);
ClearStatus();
}
setlinestyle(SOLID_LINE,1,1);
}
}

void rotate()
{
char* charangle;
int angle;
float rad;
int x,y;
int xf=marker.left;/*/(marker.left-marker.right)/2+marker.left;*/
int yf=marker.bottom;/*/(marker.bottom-marker.top)/2+marker.top; */
int row,col;
int pixel;
FILE* temp; /* added code*/

if(!marked) return;

charangle=readline(" Enter The Angle Of Rotation (&#1612;90,&#1612;180,&#1612;270) : ");
if(charangle==NULL) return;
angle=atoi(charangle);

/*added code begins*/
temp=fopen("work","w");
if(temp==NULL)
{
ShowStatus("Cannot Proceed!");
delay(1000);
ClearStatus();
return;
}

for(row=marker.top+1;row<marker.bottom;++row)
{
for(col=marker.left+1;col<marker.right;++col)
{
pixel=getpixel(col,row);
fputc(pixel,temp);
}
}
fclose(temp);

temp=fopen("work","r");
if(temp==NULL)
{
ShowStatus(" Cannot Proceed ! ");
delay(1000);
ClearStatus();
return;
}
/* added code ends */
rad=angle*M_PI/180.0;

unmark();
setwritemode(COPY_PUT);
for(row=marker.top;row<=marker.bottom;++row)
for(col=marker.left;col<=marker.right;++col)
putpixel(col,row,WHITE);
for(row=marker.top+1;row<marker.bottom;++row)
{
for(col=marker.left+1;col<marker.right;++col)
{
/* pixel=getpixel(col,row); */
pixel=fgetc(temp);
x=ceil((1-cos(rad))*(xf)+sin(rad)*(yf)+col*cos(rad)-row*sin(rad));
y=ceil((1-cos(rad))*(yf)-sin(rad)*(xf)+col*sin(rad)+row*cos(rad));
/*x=(col-xf)*cos(rad)+(yf-row)*sin(rad)+xf;*/
/*y=(col-xf)*sin(rad)+(row-yf)*cos(rad)+yf;*/
if(x>=MIN_X+2&&x<=MAX_X-2&&y>=MIN_Y+2&&y<=MAX_Y-2)
{
putpixel(x,y,pixel);
putpixel(x+1,y,pixel);
putpixel(x,y+1,pixel);
putpixel(x,y-1,pixel);
putpixel(x-1,y,pixel);
}

}
}

}

char* readline(char* msg)
{
char* Line;
char temp[40];
char Disp_Line[60];
char ch;
int i=0,length=0;
int max=((475-12)-strlen(msg)*8)/8;/*/ find maximum number of characters*/

ClearStatus();
setcolor(BLACK);
outtextxy(12,464,msg);
strcpy(Disp_Line,msg);

ch=getch();
while( (ch!=27)&& (ch!=13))
{
switch (ch)
{
case '\b' : if(i==0)
beep();
else
{
i--;
ClearStatus();
length=strlen(Disp_Line);
Disp_Line[length-1]='\0';
setcolor(BLACK);
outtextxy(12,464,Disp_Line);

}

break;
default : if(i > max)
beep();
else
{
length=strlen(Disp_Line);
Disp_Line[length]=ch;
Disp_Line[length+1]='\0';
outtextxy(12,464,Disp_Line);
temp[i++]=ch;
}
break;
}
ch=getch();
}

temp[i]='\0';
ClearStatus();
if(ch==27)
return NULL;
else
{
Line=(char*)malloc(strlen(temp)+1);
strcpy(Line,temp);
}
return Line;
}

void scale()
{
int left,right,bottom,top;
float x,y;
float Sx,Sy;
float i,j;
int row,col;
int pixel;
int check_scale_done=0;
FILE* temp;

if(!marked) return;

while(1)
{
if(RightButtonPressed)
return;
else
{
showmouseptr();
if(!check_mouse_on(marker.left,marker.top,marker.right,marker.bottom))
{
startmouse(marker.right,marker.bottom);
setcolor(15-BLACK);
setlinestyle(DOTTED_LINE,1,1);
setwritemode(XOR_PUT);
}
left=marker.left;right=marker.right;top=marker.top;bottom=marker.bottom;
restrictmouseptr(left,top,MAX_X-2,MAX_Y-2);
delay(1000);
hidemouseptr();
while(LeftButtonPressed)
{
getxy();
if(mousex!=prevx||mousey!=prevy)
{
rectangle(left,top,right,bottom);
right=mousex;
bottom=mousey;
rectangle(left,top,right,bottom);
disp_coord();
}
}
showmouseptr();
rectangle(left,top,right,bottom);

marked=0;
setlinestyle(SOLID_LINE,1,1);
setwritemode(COPY_PUT);

Sx=((float)(right-left))/(marker.right-marker.left);
Sy=((float)(bottom-top))/(marker.bottom-marker.top);

temp=fopen("work","w");
if(temp==NULL)
{
ShowStatus("Cannot Proceed!");
delay(1000);
ClearStatus();
return;
}

for(row=marker.top;row<=marker.bottom;++row)
{
for(col=marker.left;col<=marker.right;++col)
{
pixel=getpixel(col,row);
fputc(pixel,temp);
}
}
fclose(temp);

temp=fopen("work","r");
if(temp==NULL)
{
ShowStatus(" Cannot Proceed ! ");
delay(1000);
ClearStatus();
return;
}

for(y=top;y<=bottom;y+=Sy)
{
for(x=left;x<=right;x+=Sx)
{
pixel=fgetc(temp);
for(j=0;j<=Sy;j++)
{
for(i=0;i<=Sx;i++)
{
putpixel((int)(ceil(x+i)),(int)(ceil(y+j)),pixel);
}
}

}
}

check_scale_done=1;
}/* end of else*/
if(check_scale_done==1)
{
check_scale_done=0;
break;
}
}
fclose(temp);
restrictmouseptr(0,0,640,480);
}

void topic()
{
hidemouseptr();

int x1,y1,x2,y2;
x1=(MAX_X+MIN_X)/2-100;
y1=(MIN_Y+MAX_Y)/2-38;
x2=(MAX_X+MIN_X)/2+100;
y2=(MIN_Y+MAX_Y)/2+38;
int i,j;
/*
int temp=Current_Color;
int temp1=Current_Pattern;
*/
int area=imagesize(x1,y1,x2,y2);
char*buffer=(char*)malloc(area);
getimage(x1,y1,x2,y2,buffer);
//setfillstyle(SOLID_FILL,BLUE);
//bar(x1,y1,x2,y2);
ShowStatus("press any key to continue");
for(i=x1;i<x2;i++)
for(j=y1;j<y2;j++)
{
if(i>x1+10 && i<x2-10 && j>y1+4 && j<y2-6)
putpixel(i,j,GREEN);
else
putpixel(i,j,BLUE);
}

//setfillstyle(SOLID_FILL,GREEN);
//bar(x1+30,y1+15,x2-30,y2-15);
outtextxy(x1+26,y1+7,"Look at the bottom ");
outtextxy(x1+15,y1+20,"left corner for tips. ");
outtextxy(x1+13,y1+33,"For further help ,read ");

outtextxy(x1+12,y1+46,"the manual,a chm file ");
outtextxy(x1+12,y1+59,"given with this editor");
//sleep(3);
getch();
putimage(x1,y1,buffer,COPY_PUT);
showmouseptr();
//setfillstyle(temp1,temp);

free(buffer);
}

void about()
{
hidemouseptr();

int x1,y1,x2,y2;
x1=(MAX_X+MIN_X)/2-100;
y1=(MIN_Y+MAX_Y)/2-38;
x2=(MAX_X+MIN_X)/2+100;
y2=(MIN_Y+MAX_Y)/2+38;
int i,j;
/*
int temp=Current_Color;
int temp1=Current_Pattern;
*/
int area=imagesize(x1,y1,x2,y2);
char*buffer=(char*)malloc(area);
getimage(x1,y1,x2,y2,buffer);
//setfillstyle(SOLID_FILL,BLUE);
//bar(x1,y1,x2,y2);
ShowStatus("press any key to continue");
for(i=x1;i<x2;i++)
for(j=y1;j<y2;j++)
{
if(i>x1+8 && i<x2-8 && j>y1+3 && j<y2-8)
putpixel(i,j,GREEN);
else
putpixel(i,j,BLUE);
}

//setfillstyle(SOLID_FILL,GREEN);
//bar(x1+30,y1+15,x2-30,y2-15);
outtextxy(x1+12,y1+7,"Coded and Developed by");
outtextxy(x1+30,y1+20,"Jagat Sastry P.");
outtextxy(x1+13,y1+33,"Charith Chowdary K.P.");

outtextxy(x1+13,y1+46,"2nd yr computer Engg");
outtextxy(x1+35,y1+59,"NITK Surathkal");
//sleep(3);
getch();
putimage(x1,y1,buffer,COPY_PUT);
showmouseptr();
//setfillstyle(temp1,temp);

free(buffer);
}

void end_about()
{
hidemouseptr();

int x1,y1,x2,y2;
x1=(MAX_X+MIN_X)/2-100;
y1=(MIN_Y+MAX_Y)/2-38;
x2=(MAX_X+MIN_X)/2+100;
y2=(MIN_Y+MAX_Y)/2+38;
int i,j;
/*
int temp=Current_Color;
int temp1=Current_Pattern;
*/
//int area=imagesize(x1,y1,x2,y2);
//char*buffer=(char*)malloc(area);
//getimage(x1,y1,x2,y2,buffer);
//setfillstyle(SOLID_FILL,BLUE);
//bar(x1,y1,x2,y2);
ShowStatus("press any key to exit");
for(i=x1;i<x2;i++)
for(j=y1;j<y2;j++)
{
if(i>x1+8 && i<x2-8 && j>y1+3 && j<y2-8)
putpixel(i,j,GREEN);
else
putpixel(i,j,BLUE);
}

//setfillstyle(SOLID_FILL,GREEN);
//bar(x1+30,y1+15,x2-30,y2-15);
outtextxy(x1+12,y1+7,"Coded and Developed by");
outtextxy(x1+30,y1+20,"Jagat Sastry P.");
outtextxy(x1+13,y1+33,"Charith Chowdary K.P.");

outtextxy(x1+13,y1+46,"2nd yr computer Engg");
outtextxy(x1+35,y1+59,"NITK Surathkal");
//sleep(3);
getch();
//putimage(x1,y1,buffer,COPY_PUT);
showmouseptr();
//setfillstyle(temp1,temp);

//free(buffer);
}


void create_box(int l,int t,int r,int b,int c,int c1,int c2)
{
int fc=CYAN;
setfillstyle(1,c);
setlinestyle(0,1,0);
setcolor(0);
bar(l,t,r,b);
setcolor(c1);
line(l,t,l,b);
line(l,t,r,t);
setcolor(c2);
line(r,t,r,b);
line(l,b,r,b);
setcolor(fc);
}

void new_file()
{
if(marked) unmark();
hidemouseptr();
if(!saved)
{
ShowStatus("Save Changes ? ");
char ch=getch();
if(ch=='y'||ch=='Y')
save();

}
strcpy(FileName,"Untitled");
disp_filename();
setfillstyle(SOLID_FILL,WHITE);
bar(MIN_X+2,MIN_Y+2,MAX_X-2,MAX_Y-2);
draw_button_border(Current_Button);
undraw_button_border(Prev_Button);
Current_Button=Prev_Button;
setfillstyle(Current_Pattern,Current_Color);
showmouseptr();
}

void save()
{
char* name;
FILE* out;
char ch;
int row,col;
int byte;
hidemouseptr();
if(strcmp(FileName,"Untitled")==0)
{
name=readline("Save File As : ");
if(name==NULL) return;
}
else
{ name=(char*)malloc(strlen(FileName)+1);
strcpy(name,FileName);
}

out=fopen(name,"w");
if(out==NULL)
{
ShowStatus(" Error Opening File !");
delay(1000);
ClearStatus();
return;
}

ShowStatus(" Saving File (Please Wait) ");

for(row=MIN_Y+2;row<=MAX_Y-2;++row)
{
for(col=MIN_X+2;col<=MAX_X-2;)
{
byte=getpixel(col,row);
byte=byte<<4;
col++;
byte+=getpixel(col,row);
col++;
if(fputc(byte,out)==EOF)
{
ShowStatus("Error Writing FIle ! ");
delay(1000);
ClearStatus();
free(name);
fclose(out);
}
}
}
ClearStatus();
strcpy(FileName,name);
disp_filename();
free(name);
fclose(out);
saved=1;
showmouseptr();
}

void load()
{
FILE* in;
char* name;
char ch;
int byte;
int row,col;
int temp;
if(!saved)
{
ShowStatus(" Save Current File ? ");
ch=getch();
if(ch=='y'||ch=='Y')
{
save();
}
}

name=readline(" Enter File To Load : ");
if(name==NULL)
return;

in=fopen(name,"r");
if(fopen==NULL)
{
ShowStatus(" Error Opening File ");
delay(1000);
ClearStatus();
return;
}

byte=fgetc(in);

for(row=MIN_Y+2;row<=MAX_Y-2;row++)
{
for(col=MIN_X+2;col<=MAX_X-2;)
{
temp=(byte&0xf0)>>4;
putpixel(col,row,temp);
col++;
temp=(byte&0x0f);
putpixel(col,row,temp);
col++;
byte=fgetc(in);
if(byte==EOF)
{
return;
}
}
}
strcpy(FileName,name);
disp_filename();
free(name);
fclose(in);
saved=1;
}

void dark()
{ hidemouseptr();
for(int i=MIN_X;i<=MAX_X;i++)
for(int j=MIN_Y;j<=MAX_Y;j++)
{
if(getpixel(i,j)==10)
putpixel(i,j,2);
if(getpixel(i,j)==12)
putpixel(i,j,4);
if(getpixel(i,j)==11)
putpixel(i,j,9);
if(getpixel(i,j)==13)
putpixel(i,j,5);
if(getpixel(i,j)==7)
putpixel(i,j,8);
}
showmouseptr();
}

void light()
{ hidemouseptr();
for(int i=MIN_X;i<=MAX_X;i++)
for(int j=MIN_Y;j<=MAX_Y;j++)
{
if(getpixel(i,j)==2)
putpixel(i,j,10);
if(getpixel(i,j)==4)
putpixel(i,j,12);
if(getpixel(i,j)==9)
putpixel(i,j,11);
if(getpixel(i,j)==5)
putpixel(i,j,13);
if(getpixel(i,j)==8)
putpixel(i,j,7);
}
showmouseptr();
}

void invert()
{ hidemouseptr();
for(int i=MIN_X;i<=MAX_X;i++)
for(int j=MIN_Y;j<=MAX_Y;j++)
{
putpixel(i,j,15-getpixel(i,j));
}
showmouseptr();
}

void blackwhite()
{ hidemouseptr();
for(int i=MIN_X;i<=MAX_X;i++)
for(int j=MIN_Y;j<=MAX_Y;j++)
{
if(getpixel(i,j)==1)
putpixel(i,j,0);
if(getpixel(i,j)==2)
putpixel(i,j,7);
if(getpixel(i,j)==3)
putpixel(i,j,7);
if(getpixel(i,j)==4)
putpixel(i,j,8);
if(getpixel(i,j)==5)
putpixel(i,j,8);
if(getpixel(i,j)==6)
putpixel(i,j,8);
if(getpixel(i,j)==9)
putpixel(i,j,8);
if(getpixel(i,j)==10)
putpixel(i,j,7);
if(getpixel(i,j)==11)
putpixel(i,j,7);
if(getpixel(i,j)==12)
putpixel(i,j,7);
if(getpixel(i,j)==13)
putpixel(i,j,7);
if(getpixel(i,j)==14)
putpixel(i,j,7);
}
showmouseptr();
}

int main()
{
int g=DETECT,i,j,m,closeflag=0,tempx=0,tempy=0;
initgraph(&g,&m,"c:\\tc\\bgi");
if(graphresult())
{
printf("\n Couldn't initialise graphics.... we tried our level best\n");
exit(1);
}
if(initmouse()==0)
{
printf("\n We tried hard but couldn't initialise mouse\n");
exit(1);
}
start_up();
init();
disp_filename();
showmouseptr();
while(1)
{

getmousepos(&button,&x,&y);
getxy();
//check_if_color();

disp_coord();
//highlighting close button
/*
if(x!=tempx || y!=tempy)
{
showstatus(x,y);
}
*/
if(x>617 && x<629 && y>6 && y<17 )
{
if(closeflag!=1)
{
//setfillstyle(1,1);
hidemouseptr();
//floodfill(619,8,LIGHTRED);
for(i=618;i<629;i++)
for(j=7;j<=16;j++)
if(getpixel(i,j)!=WHITE)
putpixel(i,j,6);
showmouseptr();
closeflag=1;
}
}
else if(closeflag==1)
{
hidemouseptr();
for(i=618;i<629;i++)
for(j=7;j<=16;j++)
if(getpixel(i,j)!=WHITE)
putpixel(i,j,BLUE);
showmouseptr();
closeflag=0;
} //highlighting closebutton ends

if(button==1)
{
int fll=0;
if(check_if_button_pressed());
//IF THE CLOSE BUTTON IS PRESSED
if(x>617 && x<629 && y>6 && y<17)
quit();
//IF DROP DOWN MENU IS CLICKED
if(x>88&&y>17&&x<88+80&&y<37)
{
showfilemenu(88,17,80,20,x,y);
fll=1;
//button==0;
//LeftButtonPressed=0;
//RightButtonPressed=0;
//undraw_button_border(Current_Button);
//Current_Button=16;
}
else if(x>88+82&&y>17&&x<88+2*80&&y<37)
{
showeditmenu(88+82,17,80,20,x,y);
fll=1;
//button==0;
//LeftButtonPressed=0;
//RightButtonPressed=0;
//undraw_button_border(Current_Button);
//Current_Button=16;
}
else if(x>88+82*2&&y>17&&x<88+3*80&&y<37)
{
showformatmenu(88+2*82+2,17,80,20,x,y);
fll=1;
//button==0;
//LeftButtonPressed=0;
//RightButtonPressed=0;
//undraw_button_border(Current_Button);
//Current_Button=16;
}
else if(x>88+3*82&&y>17&&x<88+4*80&&y<37)
{
showhelpmenu(88+3*82+3,17,80,20,x,y);
fll=1;
//button==0;
//LeftButtonPressed=0;
//RightButtonPressed=0;
//undraw_button_border(Current_Button);
//Current_Button=16;
}
if(fll==1)
undraw_button_border(Current_Button);


else if(check_if_color())
{
ClearStatus();
//ShowStatus("Select the Pattern and Colour That You Want");
}
else if(check_mouse_on(MIN_X+2,MIN_Y+2,MAX_X-2,MAX_Y-2))
{
ClearStatus();
saved=0; //file has been altered;
if(fll!=1)
Diagram();
}
else check_if_exit();
}
else check_if_button_pressed();
tempx=x;
tempy=y;
}

getch();
closegraph();
return 0;
}


merci d'avance
lundi 21 février 2011 à 20:08:42 | Re : error LNK2001: unresolved external symbol _WinMainCRTStartup

BruNews

Administrateur CodeS-SourceS
Ce code fait du 16 bits mode reel (ultra obsolete), ne compilera jamais sur VC++.

ciao...
BruNews, MVP VC++
lundi 21 février 2011 à 22:23:17 | Re : error LNK2001: unresolved external symbol _WinMainCRTStartup

CrKa

merci

Mais, je ne comprenais pas ce que vous entendez sur 16 bits mode reel (ultra obsolete)


Cette discussion est classée dans : int, void, x1, y1, if


Répondre à ce message

Sujets en rapport avec ce message

faire des conversions de Type de données en integer [ par laura1978 ] ReSalutj'aimerai demander si mes types de données ont étés bien convertir, car j'aimerai avoir des resultats en Integer:Mon code:void DrehmatrixKonver aide jeux par C [ par ousous09 ] voila, quand je compile ca me donne cette erreur size of indefined or zero j'ai rien compris voila mon programme en C #include #include #include turbo c++ [ par habhoubnatour ] salut je suis libanaise et j' ai un projet a faire un programme sur turbo c++ qui fait le meme travaille que le paint le programme sur windows pour de Probleme morpion en SDL c++ [ par juju116 ] Salut tout le monde! j'expose donc mon souci pour l'instant mon programme affiche une image en fond d'ecran et bizarement cette image est bien chargé aide pour ajouter 2 nombre au tableau [ par Rido159 ] [size=100][b]Bonjour je suis débutant en C, j ai besoin de votre aide svp [^^mad5] j ai déclarer un tableau , j ai fais l'initialisation mais je suis serveur http en c probleme d'affichage des images [ par httpcouic ] Bonjour, j'ai un serveur http à coder le problème c'est que je n'arrive pas à afficher des images avec: je ne sais pas si c'est lié aux mimes vers la Conversion des minuscules accentuées en minuscules sans accent : impossible ? [ par ungars2 ] Bonjour, voici les messages d'erreurs de GCC pour ce code (c'est juste un exemple) : Line Location main.c:34: warning: multi-character character con tracer des points en c [ par fireman42 ] Bonjour à tous :) Pour un projet d'algorithmique, je dois écrire en C le programme suivant : a) Créer 1000 points d'abscisse de 1 à 1000 et d'ordonné Problème classe et main : argument does not match [ par RS8 ] Bonjour,je fais actuellement de 'lOpenGL.Je voudrais avoir deux fichiers : drawing.cpp et main.cppDans le main.cpp il n'y a que le main et dans drawin Communiquer entre processus avec des pipe [ par akrogames ] Bonjour, Je souhaite réaliser un programme pour m'entrainer à créer des anneaux avant de passer à la programmation socket. Mon objectif : faire pass


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,530 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales