Header file:
graphics.h
Synopsis:
void getviewsettings(struct viewporttype *viewport);
struct viewporttype {
int left, top;
int right, bottom, clip;
};
Description:
getviewsettings() gets current viewport information.
getviewsettings function in c graphics
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void) {
/* request auto detection */
int graphicDriver = DETECT, graphicMode, err;
struct viewporttype info;
char topleft[32], botright[32], clip[32];
/* initialize graphics and local variables */
initgraph(&graphicDriver, &graphicMode,
"C:/TURBOC3/BGI");
/* read result of initialization */
err = graphresult();
if (err != grOk) {
/* an error occurred */
printf("Graphics error: %s\n",
grapherrormsg(err));
getch();
return 0;
}
/* get information about current viewport */
getviewsettings(&info);
/* convert text information into strings */
sprintf(topleft, "Top Left (%d, %d)", info.left, info.top);
sprintf(botright, "Bottom Right (%d, %d)", info.right, info.bottom);
sprintf(clip, "Clipping is turned %s.", info.clip?"ON":"OFF");
/* display the information */
outtextxy(10, 10, topleft);
outtextxy(10, 30, botright);
outtextxy(10, 50, clip);
/* clean up */
getch();
closegraph();
return 0;
}
Output: (getviewsettings built-in function in c graphics.h)
No comments:
Post a Comment