[GRASSLIST:1606] Re: G_write_colors()

Massimiliano Cannata massimiliano.cannata at supsi.ch
Thu Oct 30 03:56:38 EST 2003


Thanks a lot,
Now everythings works!
I had done in that way becouse i thougth i had segmantation falult caused by
struct Colors *colr while the problem was a pointer conflict with a char *.
I had a question about programming in GRASS:

how can be done a debug of GRASS command in linux environment like is done for
generic C programs?
I try Anjuta but I can only compile the command and cannot build it... and so
cannot debug....

Thanks for your precious support.
Massimiliano

Glynn Clements wrote:

> Massimiliano Cannata wrote:
>
> > I have a problem setting the color in a raster
> > map,
> > in my C file i call:
> >
> > .......
> > ......
> > char *name,*result, *mapset;
> > struct Colors *colr;
> >
> > name = input->answer;
> > result = output->answer;
> > mapset = G_find_cell2(name,"");
> >
> > G_init_colors(colr);
>
> "colr" is pointing at a random memory location. Change your code to:
>
>         struct Colors colr;
>         ...
>         G_init_colors(&colr);
>         G_add_color_rule((CELL)-50, 0,0,255, (CELL)0, 255,255,255, &colr);
>         G_add_color_rule((CELL)0, 255,255,255, (CELL)50, 255,0,0, &colr);
>         G_write_colors(result,mapset,&colr);
>         G_free_colors(&colr);
>
> This applies in most situations where a function accepts a pointer as
> an argument; not just in GRASS, but in C generally.
>
> --
> Glynn Clements <glynn.clements at virgin.net>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20031030/4808ecc9/attachment.html


More information about the grass-user mailing list