FreeBASIC  0.91.0
gfx_paletteget.c
Go to the documentation of this file.
1 /* retrieve certain color from current palette */
2 
3 #include "fb_gfx.h"
4 
5 FBCALL void fb_GfxPaletteGet(int index, int *r, int *g, int *b)
6 {
7  unsigned int color;
8 
9  if (!__fb_gfx)
10  return;
11 
12  index &= (__fb_gfx->default_palette->colors - 1);
13  color = __fb_gfx->device_palette[index];
14  if (!g) {
15  *r = (color & 0xFCFCFC) >> 2;
16  }
17  else {
18  *r = color & 0xFF;
19  *g = (color & 0xFF00) >> 8;
20  *b = (color & 0xFF0000) >> 16;
21  }
22 }