This blog is under construction

Wednesday, 11 September 2013

getbkcolor example in c

Header file:
    graphics.h

Synopsis:
     int getbkcolor (void);

Description:
     getbkcolor() returns the current background color



getbkcolor function in c graphics



  #include <graphics.h>
  #include <stdlib.h>
  #include <string.h>
  #include <stdio.h>
  #include <conio.h>

  int main(void) {
        /* request auto detection */
        int graphicDriver = DETECT, graphicMode;
        int err, bcol;
        char color[35];

        /* initialize graphics and local variables */
        initgraph(&graphicDriver, &graphicMode,
                                        "C:/TURBOC3/BGI");

        /* read result of initialization */
        err = graphresult();

        if (err != grOk) {
                /* error occurred */
                printf("Graphic Error: %s\n",
                                grapherrormsg(err));
                return 0;
        }

        setcolor(12);

        /* for centering text on the display */
        settextjustify(CENTER_TEXT, CENTER_TEXT);

        /* get the current background color */
        bcol = getbkcolor();

        /* convert color value into a string */
        sprintf(color, " Background color code is %d", bcol);

        /* display a message */
        outtextxy(getmaxx() / 2, getmaxy() / 2, color);

        /* clean up */
        getch();
        closegraph();
        return 0;

  }




Output: (getbkcolor built-in function in c graphics.h)


No comments:

Post a Comment