This blog is under construction

Saturday 14 September 2013

getpalettesize example in c

Header file:
    graphics.h

Synopsis:
      int getpalettesize(void);
     
Description:
     getpalettesize() returns size of palette color look up table.


getpalettesize function in c graphics



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

  int main() {
        /* request auto detection */
        int graphicDriver = DETECT, graphicMode;
        int err;
        char psz[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("Graphic Error: %s\n",
                                grapherrormsg(err));
                getch();
                return 0;
        }


        /* convert palette size info. into string */
        sprintf(psz, "Palette size is %d", getpalettesize());

        /* display the information */
        outtextxy(100, 100, psz);

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





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


No comments:

Post a Comment