GRASS Programmer's Manual
6.4.1(2011)
|
00001 #include <grass/gis.h> 00002 #include "G.h" 00003 00004 00023 int 00024 G_get_raster_row_colors(int fd, int row, struct Colors *colors, 00025 unsigned char *red, unsigned char *grn, 00026 unsigned char *blu, unsigned char *nul) 00027 { 00028 static void *array; 00029 static int array_size; 00030 static unsigned char *set; 00031 static int set_size; 00032 00033 int cols = G__.window.cols; 00034 int type = G__.fileinfo[fd].map_type; 00035 int size = G_raster_size(type); 00036 void *p; 00037 int i; 00038 00039 if (array_size < cols * size) { 00040 array_size = cols * size; 00041 array = (DCELL *) G_realloc(array, array_size); 00042 } 00043 00044 if (set_size < cols) { 00045 set_size = cols; 00046 set = G_realloc(set, set_size); 00047 } 00048 00049 if (G_get_raster_row(fd, array, row, type) < 0) 00050 return -1; 00051 00052 if (nul) 00053 for (i = 0, p = array; i < cols; i++, p = G_incr_void_ptr(p, size)) 00054 nul[i] = G_is_null_value(p, type); 00055 00056 G_lookup_raster_colors(array, red, grn, blu, set, cols, colors, type); 00057 00058 return 0; 00059 }