Header file:
graphics.h
Synopsis:
unsigned setgraphbufsize(unsigned bufsize);
Description:
setgraphbufsize() returns size of the previous buffer and set the given size for the internal graphic buffer.
setgraphbufsize function in c graphics
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#define BUFSZ 1024 /* internal graphics buffer size */
int main(void) {
/* request auto detection */
int graphicDriver = DETECT, graphicMode;
int err, midx, midy, prevsz;
char str[64];
/* setting the size of the interal graphic buffer */
prevsz = setgraphbufsize(BUFSZ);
/* initialize graphics and local variables */
initgraph(&graphicDriver, &graphicMode,
"C:/TURBOC3/BGI");
/* read result of initialization */
err = graphresult();
if (err != grOk) {
/* an error occurred */
printf("Graphic Error: %s\n", grapherrormsg(err));
getch();
return 0;
}
/* mid position in x and y axis */
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* output some messages */
sprintf(str, "Current Graphics Buffer Size: %d", BUFSZ);
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(midx, midy, str);
sprintf(str, "Previous Graphics Buffer Size: %d", prevsz);
outtextxy(midx, midy+textheight("H"), str);
/* clean up */
getch();
closegraph();
return 0;
}
Output: (setgraphbufsize built-in function in c graphics.h)
No comments:
Post a Comment