GRASS Programmer's Manual
6.4.2(2012)
|
00001 00002 #include <stdio.h> 00003 #include <stdlib.h> 00004 00005 #include <grass/gis.h> 00006 #include <grass/colors.h> 00007 #include "psdriver.h" 00008 00009 void init_color_table(void) 00010 { 00011 NCOLORS = true_color ? (1 << 24) : (1 << 8); 00012 } 00013 00014 static int get_color_rgb(int r, int g, int b) 00015 { 00016 return (r << 16) + (g << 8) + b; 00017 } 00018 00019 static int get_color_gray(int r, int g, int b) 00020 { 00021 return (int)(r * 0.299 + g * 0.587 + b * 0.114); 00022 } 00023 00024 int PS_lookup_color(int r, int g, int b) 00025 { 00026 return true_color ? get_color_rgb(r, g, b) 00027 : get_color_gray(r, g, b); 00028 }