Header file:
graphics.h
Synopsis:
struct palettetype * getdefaultpalette(void);
struct palettetype {
unsigned char size; /* no of colors in the palette */
signed char colors[MAXCOLORS + 1]; /* contains color nos corresponds to colors in the palette */
}
Description:
getdefaultpalette() returns palette information for the current graphic driver.
getdefaultpalette function in c graphics
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void) {
/* request auto detection */
int graphicDriver = DETECT, graphicMode;
int err, i;
/* structure for returning palette copy */
struct palettetype far *palette = NULL;
/* 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));
return 0;
}
setcolor(12);
/* return a pointer to the default palette */
palette = getdefaultpalette();
for (i=0; i<16; i++) {
printf("colors[%d] = %d\n", i, palette->colors[i]);
}
getch();
/* clean up */
closegraph();
return 0;
}
Output: (getdefaultpalette function in c graphics.h)
No comments:
Post a Comment