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