Monday, July 29, 2024

add graphics.h in DEV C/C++

 

step 1: 

download files:


https://drive.google.com/file/d/1ULN_XcrbDkls2U2DlYkNM_yiua5h-_NI/view?pli=1



step 2:

Copy libbgi.a to the lib folder of Dev C++. The default location is C:\Program Files (x86)\Dev-Cpp\MinGW64\lib.


step 3: 

Copy graphics.h and winbgim.h to the include folder of Dev C++. The default location is C:\Program Files (x86)\Dev-Cpp\MinGW64\include.


step4 :

Open Dev C++ and go to Tools -> Compiler Options. Select the Parameters tab and check the box for “Add the following commands when calling the linker”.

In the linker text area, paste the following commands:


-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32


. These are the required linkers for graphics.h file.



step 5:


 #include<graphics.h>  

#include<conio.h>  

#include<stdio.h>  

int main()  

{  

    int gd = DETECT ,gm, i;  

    float x, y,dx,dy,steps;  

    int x0, x1, y0, y1;  

    initgraph(&gd, &gm, "C:\\TC\\BGI");  

    setbkcolor(WHITE);  

    x0 = 100 , y0 = 200, x1 = 500, y1 = 300;  

    dx = (float)(x1 - x0);  

    dy = (float)(y1 - y0);  

    if(dx>=dy)  

           {  

        steps = dx;  

    }  

    else  

           {  

        steps = dy;  

    }  

    dx = dx/steps;  

    dy = dy/steps;  

    x = x0;  

    y = y0;  

    i = 1;  

    while(i<= steps)  

    {  

        putpixel(x, y, RED);  

        x += dx;  

        y += dy;  

        i=i+1;  

    }  

    getch();  

    closegraph();  

}  

//ADVERTISEMENT


output>





No comments:

Post a Comment