6 #include <grass/colors.h>
9 static int r_shift, g_shift, b_shift, a_shift;
10 static int Red[256], Grn[256], Blu[256];
12 static void set_color(
int i,
int red,
int grn,
int blu)
20 static void init_colors_rgb(
void)
38 static void init_colors_indexed(
void)
51 set_color(n_pixels++, 0, 0, 0);
53 for (r = 0; r < 6; r++) {
54 for (g = 0; g < 6; g++) {
55 for (b = 0; b < 6; b++) {
56 int red = r * 0xFF / 5;
57 int grn = g * 0xFF / 5;
58 int blu = b * 0xFF / 5;
60 set_color(n_pixels++, red, grn, blu);
66 set_color(n_pixels++, 0, 0, 0);
68 for (i = 0; i < 256; i++) {
82 init_colors_indexed();
85 static int get_color_rgb(
int r,
int g,
int b,
int a)
87 return (r << r_shift) + (g << g_shift) + (b << b_shift) + (a << a_shift);
90 static int get_color_indexed(
int r,
int g,
int b,
int a)
98 static void get_pixel_rgb(
unsigned int pixel,
int *r,
int *g,
int *b,
int *a)
100 *r = (pixel >> r_shift) & 0xFF;
101 *g = (pixel >> g_shift) & 0xFF;
102 *b = (pixel >> b_shift) & 0xFF;
103 *a = (pixel >> a_shift) & 0xFF;
106 static void get_pixel_indexed(
unsigned int pixel,
int *r,
int *g,
int *b,
116 void get_pixel(
unsigned int pixel,
int *r,
int *g,
int *b,
int *a)
119 get_pixel_rgb(pixel, r, g, b, a);
121 get_pixel_indexed(pixel, r, g, b, a);
127 : get_color_indexed(r, g, b, a);
132 return true_color ? ((r << 16) | (g << 8) | (b << 0))
void get_pixel(unsigned int pixel, int *r, int *g, int *b, int *a)
void init_color_table(void)
int G_is_little_endian(void)
Tests for little ENDIAN.
unsigned char png_palette[256][4]
int PNG_lookup_color(int r, int g, int b)
unsigned int get_color(int r, int g, int b, int a)