~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/gis/get_row_colr.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <grass/gis.h>
2
 
#include "G.h"
3
 
 
4
 
 
5
 
/*!
6
 
 * \brief 
7
 
 *
8
 
 * Reads a row of raster data and converts it to red,
9
 
 * green and blue components according to the <em>colors</em> parameter.
10
 
 * This provides a convenient way to treat a raster layer as a color
11
 
 * image without having to explicitly cater for each of <tt>CELL</tt>, <tt>FCELL</tt> and <tt>DCELL</tt> types
12
 
 *
13
 
 *  \param fd
14
 
 *  \param row
15
 
 *  \param colors
16
 
 *  \param red
17
 
 *  \param grn
18
 
 *  \param blu
19
 
 *  \param nul
20
 
 *  \return int
21
 
 */
22
 
 
23
 
int
24
 
G_get_raster_row_colors(int fd, int row, struct Colors *colors,
25
 
                        unsigned char *red, unsigned char *grn,
26
 
                        unsigned char *blu, unsigned char *nul)
27
 
{
28
 
    static void *array;
29
 
    static int array_size;
30
 
    static unsigned char *set;
31
 
    static int set_size;
32
 
 
33
 
    int cols = G__.window.cols;
34
 
    int type = G__.fileinfo[fd].map_type;
35
 
    int size = G_raster_size(type);
36
 
    void *p;
37
 
    int i;
38
 
 
39
 
    if (array_size < cols * size) {
40
 
        array_size = cols * size;
41
 
        array = (DCELL *) G_realloc(array, array_size);
42
 
    }
43
 
 
44
 
    if (set_size < cols) {
45
 
        set_size = cols;
46
 
        set = G_realloc(set, set_size);
47
 
    }
48
 
 
49
 
    if (G_get_raster_row(fd, array, row, type) < 0)
50
 
        return -1;
51
 
 
52
 
    if (nul)
53
 
        for (i = 0, p = array; i < cols; i++, p = G_incr_void_ptr(p, size))
54
 
            nul[i] = G_is_null_value(p, type);
55
 
 
56
 
    G_lookup_raster_colors(array, red, grn, blu, set, cols, colors, type);
57
 
 
58
 
    return 0;
59
 
}