# include <stdio.h>
# include <conio.h>
# include <graphics.h>
void main()
{
int dx,dy,x,y,p,x1,y1,x2,y2;
int gd,gm;
clrscr();
printf("\n\n\tEnter the co-ordinates of first point : ");
scanf("%d %d",&x1,&y1);
printf("\n\n\tEnter the co-ordinates of second point : ");
scanf("%d %d",&x2,&y2);
dx = (x2 - x1);
dy = (y2 - y1);
p = 2 * (dy) - (dx);
x = x1;
y = y1;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"e:\\tc\\bgi");
putpixel(x,y,WHITE);
while(x <= x2)
{
if(p < 0)
{
x=x+1;
y=y;
p = p + 2 * (dy);
}
else
{
x=x+1;
y=y+1;
p = p + 2 * (dy - dx);
}
putpixel(x,y,WHITE);
}
getch();
closegraph();
}
Sunday, May 3, 2009
C Program for Bresenham line drawing algorithm
Labels: Bresenham line drawing algorithm
Posted by Angad at 10:45 AM
Subscribe to:
Post Comments (Atom)
36 comments:
this is not working for vertical line
check
(100,100,100,250)
Because this is an basic bresenham's algorithm dear. It work only for slope less than 1. Read Generalized Bresenham's algorithm for your vertical line...
To plot a pixel with 30% intensity of the drawing color,
Rohit:
how putpixel() function can be used??
will the following code work??
putpixel(20,20,0.3*Green); // 30% intensity of Green
Please help me. mail me in the following e-mail id with answer:
rohitju50@yahoo.com
this program is not working because you compile it and it gives you no error when you run it
it gives you 4 errors
please help me with answer on my e-mail is israel0045@yahoo.fr
thanks a lot!!
thanks for sharing this code...could you please share the algorithm ?
How can we make this run in VC++ or MingWC++ compiler? Need help..
PROGRAM GIVES FOUR ERRORS
LINKER ERROR: UNDIFINED SYMBOL _DETECTGRAPH IN MODULE LINE.C
PLZ SEND ANSWER TO DEEP.GARG389@YAHOO.COM
thankss alots
thAnkS.....!!!!!!
PROGRAM GIVES FOUR ERRORS
LINKER ERROR: UNDIFINED SYMBOL _DETECTGRAPH IN MODULE LINE.C
PLZ SEND ANSWER TO prathameshbhilare@yahoo.com
Use Parameter Linker.
Add these as parameter:
-L.
-lbgi
-lgdi32
-lcomdlg32
-luuid
-loleaut32
-lole32
program shows no errors while compiling but run time it shows BGI Error:Gaphics not initialized (use 'initgraph') so plz help me to avoid this type of errors give urs answers to this jogendra_m@yahoo.com
for graphics not initialized error go to file,den chng directory,den click on TC nd den select BGI instead of bin,nd ur program wil execute
wat dhelll... its nt wrkngg... holy...
SEARCH THE NET FOR HOW TO LINK THE GRAPHICS LIBRARY...
how to draw line(600,200,800,100)
WELL GUD JOB THNX FOR SHARING UR IDEAS
Well said macha joyson
YA MACHAN KAUSHICK PARAMASIVAM.E SAY HATS OF TO THE THINK
HIII KAUSHICK,JOYSON WATSUP.....GUYS...IT'S SO INTRESTING PROGRAM...
AMA MACHAN NALLA IRUKU RMBA NALLA IRUKU @U.KANNAN PANDII
Hi Hello Vanakkam @Kannan what about ur Digital System ?
HI @KAUSHICK...ITS CHO CHO EASY....ITS CENTUM I THINK SO...
Hi @bala
HAI KANNAN IM RATHAN
WHTS ABOUT UR AREARS
HII VISHNU..
HAI GUYS HE R U IM FINE I WISH THE SAME WITH U AL
KANNAN HW S U PHD ABOUT PHYTHON,JAVA,.NET
gandu tera program bhi gandu jaisa hai..... bhosdiwale yeh ubuntu lavde par chalta hi nahi.... maa ki chut error hi deta hai... lund ke bal agar program likhna nhi aata toh kyu blog bana ke apni maa chudate ho naam jayant hai mera sabka mooh mein leta hoon
FOR RUN THIS PROGRAM
LINK GRAPHICS LIBRARY
Contact 7025294384 WhatsApp
Contact 7025294384 WhatsApp
View of OS as an Extended Machine and Resource Manager
Features of 80486 and Pentium Processor
AMP Module
One-pass Macro Processors
Dependency Graph
Storage Organization
Interrupt Cycle
Classification and Prediction
Web Application Design
SAP Tutorial online training
SAP HANA BI Development Tutorial
SAP HANA Administration Tutorial
SAP FICO Tutorial
SAP CRM Tutorial
SAP CCA Tutorial
this is working or not I am not check out but I know it is working
Post a Comment