हेलो दोस्तों !
आज की इस graphics.h header file के 10 important function in C language in Hindi पोस्ट में हम graphics.h हैडर फाइल के 10 महत्वपूर्ण(important) function के बारे में जानेंगे। तो दोस्तों अगर आप इन functions को जानना चाहते है तो इस पोस्ट को अंत तक जरूर पढ़े।
इस पोस्ट के मुख्य टॉपिक्स -
- graphics.h header file क्या है ?
- graphics.h header file के 10 important functions.
- functions explanation video.
1.graphics.h header file क्या है :-
दोस्तों graphics.h file के important functions को जानने से पहले हम यह जान लेते है की graphics.h क्या होती है ?
तो दोस्तों अगर आप C प्रोग्रामिंग के बारे में थोड़ा बहुत भी जानते होंगे तो आपको यह जरूर पता होगा की graphics.h एक हैडर फाइल है क्योंकि इसकी extension .h है जोकि एक हैडर फाइल की extension है। तो graphics.h C प्रोग्रामिंग की एक pre defined हैडर फाइल है जिसका यूज़ हम अपने प्रोग्राम में कर सकते है।
लेकिन अब बात आती है की हम इसका यूज़ क्यों करें। यह हैडर फाइल किस लिए यूज़ की जाती है। तो दोस्तों C प्रोग्रामिंग में ग्राफ़िक्स से रिलेटेड किसी भी प्रोग्राम को बनाने के लिए आपको इस हैडर फाइल की जरुरत पड़ती है क्योंकि इस हैडर फाइल के अंदर ही वो सारे ग्राफ़िक्स फंक्शन डिक्लेअर है जिनकी मदद से हम ग्राफ़िक्स का प्रोग्राम बनाते है।
तो graphics.h एक C प्रोग्रामिंग की एक pre defined हैडर फाइल है जिसके अंदर ग्राफ़िक्स से रिलेटेड फंक्शन डिक्लेअर किये गए है। हमें अपने प्रोग्राम में ग्राफ़िक्स का यूज़ करने के लिए इस हैडर फाइल की जरुरत पड़ती है।
2.graphics.h header file के 10 important functions :-
तो दोस्तों अब हम graphics.h हैडर फाइल के कुछ important functions को जान लेते है।
दोस्तों वैसे तो graphics.h हैडर फाइल के अंदर काफी सारे फंक्शन्स डिक्लेअर है लेकिन आज हम उन फंक्शन्स को जानेंगे जिनका यूज़ काफी ज्यादा किया जाता है। आप भी ग्राफ़िक्स का प्रोग्राम बनाने के लिए जरूर इन फंक्शन्स का यूज़ करेंगे। तो ये है वो फंक्शन्स जिनका यूज़ ज्यादा किया जाता है -
- initgraph() function.
- closegraph() function.
- graphresult() function.
- grapherrormsg() function.
- line() function.
- circle() function.
- rectangle() function.
- arc() function.
- setcolor() function.
- setbkcolor() function.
- setfillstyle() functon.
- floodfill() function.
दोस्तों अभी हमने केवल इन फंक्शन्स के नाम जाने है अब हम इन फंक्शन्स को और विस्तार से जानेंगे वो भी example प्रोग्राम के साथ।
1.initgraph() function :-
दोस्तों initgraph फंक्शन graphics.h हैडर फाइल का सबसे important फंक्शन होता है क्योंकि यह फंक्शन ग्राफ़िक्स सिस्टम को initialize करता है। जब तक ग्राफ़िक्स सिस्टम initialize नहीं होगा तब तक हम किसी भी ग्राफ़िक्स का प्रोग्राम नहीं बना सकते है। इसलिए यह फंक्शन काफी important होता है।
यह फंक्शन ग्राफ़िक्स सिस्टम को ग्राफ़िक्स ड्राइवर को डिस्क से लोड करके और ड्राइवर्स को validate करके सिस्टम को ग्राफ़िक्स मोड में डालकर initialize करता है।
syntax :-
void far initgraph(int far *graph driver,int far *graph mode,char far *path to driver);
example program :-
#include< stdio.h >
#include< stdlib.h >
#include< conio.h >
#include< graphics.h >
void main()
{
int gd=DETECT,gm,errorcode;
clrscr();
initgraph(&gd,&gm,"");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics error %s\n",grapherrormsg(errorcode));
printf("Press any key to exit\n");
getch();
exit(1);
}else
{
printf("Graphics mode is enabled\n");
}
getch();
closegraph();
}
2.closegraph() function :-
दोस्तों यह फंक्शन ग्राफ़िक्स सिस्टम के द्वारा allocate की गई सारी मेमोरी को deallocate करता है और साथ में स्क्रीन को फिर से उसी मोड में रिस्टोर करता है जिस मोड में वह initgraph फंक्शन को काल करने से पहले थी। इस फंक्शन को प्रोग्राम के अंत में कॉल किया जाता है ताकि सारी मेमोरी को फ्री किया जा सकें।
syntax :-
void far closegraph(void);
example program :-
#include< stdio.h >
#include< stdlib.h >
#include< conio.h >
#include< graphics.h >
void main()
{
int gd=DETECT,gm,errorcode;
clrscr();
initgraph(&gd,&gm,"");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics error %s\n",grapherrormsg(errorcode));
printf("Press any key to exit\n");
getch();
exit(1);
}else
{
printf("Graphics mode is enabled\n");
}
getch();
closegraph();
}
3.graphresult() function :-
दोस्तों यह फंक्शन एक एरर कोड return करता है जो ग्राफ़िक्स के लास्ट unsuccessful ऑपरेशन के लिए होता है। एरर कोड वह कोड होता है जिससे पता चलता है की ग्राफ़िक्स से रिलेटेड कौन से एरर आई है। यह फंक्शन ग्राफ़िक्स के लास्ट unsuccessful ऑपरेशन का एरर कोड return करने के बाद फिर से एरर लेवल को grOk पर सेट कर देता है।
syntax :-
int far graphresult(void);
example program :-
#include< stdio.h >
#include< stdlib.h >
#include< conio.h >
#include< graphics.h >
void main()
{
int gd=DETECT,gm,errorcode;
clrscr();
initgraph(&gd,&gm,"");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics error %s\n",grapherrormsg(errorcode));
printf("Press any key to exit\n");
getch();
exit(1);
}else
{
printf("Graphics mode is enabled\n");
}
getch();
closegraph();
}
4.grapherrormsg() function :-
दोस्तों यह फंक्शन एरर मैसेज स्ट्रिंग के लिए एक पॉइंटर return करता है। यह फंक्शन graphresult फंक्शन के द्वारा return किये गए एरर कोड का यूज़ करके एरर मैसेज स्ट्रिंग के लिए पॉइंटर return करता है। इसका मतलब है की जो भी ग्राफ़िक्स की एरर होती है उस एरर को यह फंक्शन एरर कोड की मदद से बताता है।
syntax :-
char *far grapherrormsg(int errorcode);
example program :-
#include< stdio.h >
#include< stdlib.h >
#include< conio.h >
#include< graphics.h >
void main()
{
int gd=DETECT,gm,errorcode;
clrscr();
initgraph(&gd,&gm,"");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics error %s\n",grapherrormsg(errorcode));
printf("Press any key to exit\n");
getch();
exit(1);
}else
{
printf("Graphics mode is enabled\n");
}
getch();
closegraph();
}
5.line() function :-
यह फंक्शन किन्हीं दो निश्चित पॉइंट्स के बीच लाइन को draw करता है। अगर सरल शब्दों में कहु तो यह फंक्शन लाइन को draw करने का काम करता है। यह फंक्शन लाइन को current लाइन स्टाइल ,थिकनेस और drawing कलर के आधार पर draw करता है।
syntax :-
void far line(int x1,int y1,int x2,int y2);
example program :-
#include< stdio.h >
#include< stdlib.h >
#include< conio.h >
#include< graphics.h >
void main()
{
int gd=DETECT,gm,errorcode;
clrscr();
initgraph(&gd,&gm,"");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics error %s\n",grapherrormsg(errorcode));
printf("Press any key to exit\n");
getch();
exit(1);
}
line(150,50,500,50);
rectangle(150,100,500,150);
circle(320,250,80);
arc(320,440,1,180,80);
getch();
closegraph();
}
6.circle() function :-
यह फंक्शन circle को draw करने का काम करता है। यह फंक्शन circle को current लाइन स्टाइल ,थिकनेस और drawing कलर के आधार पर draw करता है।
syntax :-
void far circle(int x,int y,int radius);
example program :-
#include< stdio.h >
#include< stdlib.h >
#include< conio.h >
#include< graphics.h >
void main()
{
int gd=DETECT,gm,errorcode;
clrscr();
initgraph(&gd,&gm,"");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics error %s\n",grapherrormsg(errorcode));
printf("Press any key to exit\n");
getch();
exit(1);
}
line(150,50,500,50);
rectangle(150,100,500,150);
circle(320,250,80);
arc(320,440,1,180,80);
getch();
closegraph();
}
7.rectangle() function :-
यह फंक्शन rectangle को draw करने का काम करता है। यह फंक्शन rectangle को current लाइन स्टाइल ,थिकनेस और drawing कलर के आधार पर draw करता है।
syntax :-
void far rectangle(int left,int top,int right,int bottom);
example program :-
#include< stdio.h >
#include< stdlib.h >
#include< conio.h >
#include< graphics.h >
void main()
{
int gd=DETECT,gm,errorcode;
clrscr();
initgraph(&gd,&gm,"");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics error %s\n",grapherrormsg(errorcode));
printf("Press any key to exit\n");
getch();
exit(1);
}
line(150,50,500,50);
rectangle(150,100,500,150);
circle(320,250,80);
arc(320,440,1,180,80);
getch();
closegraph();
}
8.arc() function :-
यह फंक्शन सर्कुलर arc को draw करने का काम करता है। यह फंक्शन सर्कुलर arc को current लाइन स्टाइल ,थिकनेस और drawing कलर के आधार पर draw करता है।
syntax :-
void far arc(int x,int y,int stangle,int endangle,int radius);
example program :-
#include< stdio.h >
#include< stdlib.h >
#include< conio.h >
#include< graphics.h >
void main()
{
int gd=DETECT,gm,errorcode;
clrscr();
initgraph(&gd,&gm,"");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics error %s\n",grapherrormsg(errorcode));
printf("Press any key to exit\n");
getch();
exit(1);
}
line(150,50,500,50);
rectangle(150,100,500,150);
circle(320,250,80);
arc(320,440,1,180,80);
getch();
closegraph();
}
9.setcolor() function :-
दोस्तों यह फंक्शन current drawing का कलर सेट करता है। इस फंक्शन को आप जो कलर पास करेंगे यह फंक्शन उसी कलर को current drawing कलर के रूप में सेट कर देता है।
syntax :-
void far setcolor(int color);
example program :-
#include< stdio.h >
#include< stdlib.h >
#include< conio.h >
#include< graphics.h >
void main()
{
int gd=DETECT,gm,errorcode;
clrscr();
initgraph(&gd,&gm,"");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics error %s\n",grapherrormsg(errorcode));
printf("Press any key to exit\n");
getch();
exit(1);
}
setcolor(14);
setbkcolor(1);
circle(320,240,100);
setfillstyle(3,2);
floodfill(322,242,14);
getch();
closegraph();
}
10.setbkcolor() function :-
दोस्तों यह फंक्शन current बैकग्राउंड का कलर सेट करता है। इस फंक्शन को आप जो कलर पास करेंगे यह फंक्शन उसी कलर को current बैकग्राउंड कलर के रूप में सेट कर देता है।
syntax :-
void far setbkcolor(int color);
example program :-
#include< stdio.h >
#include< stdlib.h >
#include< conio.h >
#include< graphics.h >
void main()
{
int gd=DETECT,gm,errorcode;
clrscr();
initgraph(&gd,&gm,"");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics error %s\n",grapherrormsg(errorcode));
printf("Press any key to exit\n");
getch();
exit(1);
}
setcolor(14);
setbkcolor(1);
circle(320,240,100);
setfillstyle(3,2);
floodfill(322,242,14);
getch();
closegraph();
}
11.setfillstyle() function :-
यह फंक्शन drawing स्टाइल के पैटर्न और कलर को सेट करने का काम करता है। इस फंक्शन की मदद से आप drawing स्टाइल के लिए पैटर्न और कलर को सेट कर सकते है जो भी पैटर्न और कलर आप चाहते है।
syntax :-
void far setfillstyle(int pattern,int color);
example program :-
#include< stdio.h >
#include< stdlib.h >
#include< conio.h >
#include< graphics.h >
void main()
{
int gd=DETECT,gm,errorcode;
clrscr();
initgraph(&gd,&gm,"");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics error %s\n",grapherrormsg(errorcode));
printf("Press any key to exit\n");
getch();
exit(1);
}
setcolor(14);
setbkcolor(1);
circle(320,240,100);
setfillstyle(3,2);
floodfill(322,242,14);
getch();
closegraph();
}
12.floodfill() function :-
यह फंक्शन किसी bounded region को current पैटर्न और कलर से फिल करने का काम करता है। यह फंक्शन केवल bounded या enclosed एरिया को ही फिल करता है। इस फंक्शन का यूज़ हम rectangle और circle जैसे किसी enclosed एरिया को current पैटर्न और कलर से फिल करने के लिए करते है।
syntax :-
void far floodfill(int x,int y,int border);
example program :-
#include< stdio.h >
#include< stdlib.h >
#include< conio.h >
#include< graphics.h >
void main()
{
int gd=DETECT,gm,errorcode;
clrscr();
initgraph(&gd,&gm,"");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics error %s\n",grapherrormsg(errorcode));
printf("Press any key to exit\n");
getch();
exit(1);
}
setcolor(14);
setbkcolor(1);
circle(320,240,100);
setfillstyle(3,2);
floodfill(322,242,14);
getch();
closegraph();
}
3.functions explanation video :-
तो दोस्तों अगर आपको अभी भी ये फंक्शन्स अच्छी तरह समझ नहीं आये है तो आप हमारी यह वीडियो देख सकते है हमने इस वीडियो में सभी फंक्शन्स को example प्रोग्राम के साथ समझाया है। तो अगर आप इन फंक्शन्स को अच्छी तरह समझना चाहते है तो इस वीडियो को पूरा जरूर देखें। इस वीडियो को you tube पर देखने के लिए यहाँ पर क्लिक करें।
इन पोस्ट को भी पढ़े -
- stdio.h हैडर फाइल के important फंक्शन।
- stdlib.h हैडर फाइल के important फंक्शन।
- conio.h हैडर फाइल के important फंक्शन।
- math.h हैडर फाइल के important फंक्शन।
Author :- तो दोस्तों अब हमारी यह graphics.h header file के 10 important function in C language in Hindi पोस्ट ख़त्म होती है हम आशा करते है की आपको हमारी यह पोस्ट जरूर पसंद आई होगी और आप graphics.h header file के 10 important functions को जान गए होंगे। तो दोस्तों आज के लिए बस इतना ही फिर मिलेंगे ऐसी ही किसी और मजेदार पोस्ट में तब तक के लिए अलविदा !
0 Comments
Do not enter any spam comments please.