This blog is under construction

Wednesday, 11 September 2013

getfillpattern example in c

Header file:
    graphics.h

Synopsis:
      void getfillpattern(char *pattern);
     pattern - pointer to an 8 byte sequence where each byte corresponds 
                  to 8 pixel in the fetched pattern
     
Description:
     getfillpattern() gets the (current) user defined fillpattern which is set by setfillpattern().



getfillpattern function in c graphics



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

  int main(void) {
        /* request auto detection */
        int gdriver = DETECT, gmode, errorcode;
        int i, err;
        char pattern[8] = {0xffAA, 0x55, 0xffAA, 0x55,
                           0xffAA, 0x55, 0xffAA, 0x55};
        char result[8];

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

        /* read result of initialization */
        errorcode = graphresult();
        if (errorcode != grOk)  {
                /* an error occurred */
                printf("Graphics error: %s\n",
                                grapherrormsg(errorcode));
                getch();
                return 0;
        }

        setcolor(getmaxcolor());

        /* select a user defined fill pattern */
        setfillpattern(pattern, getmaxcolor());

        /* fill the screen with the pattern */
        bar(0, 0, getmaxx(), getmaxy());

        getch();

        /* get the current user defined fill pattern */
        getfillpattern(result);

        getch();

        /* clean up */
        closegraph();

        printf("Used fill pattern:\n");
        for (i = 0; i < 8; i++) {
                printf("0x%x ", result[i]);
        }

        getch();
        return 0;
  }





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


No comments:

Post a Comment