Hamish wrote:

> > > Is a new D_number_to_RGB(int color, unsigned char &r,&g,&b) fn
> > > needed in lib/display/tran_colr.c?
> Glynn:
> > Yes. E.g.:
> > 
> > int D_color_number_to_RGB(int color, int *r, int *g, int *b)
> > {
> >     const struct color_rgb *c;
> > 
> >     if (color <= 0)
> >         return 0;
> > 
> >     if (color >= ncolors)
> >         return 0;
> > 
> >     c = &colors[color];
> >     r = c->r;
> >     g = c->g;
> >     b = c->b;
> > 
> >     return 1;
> > }
> 
> there is a problem: for some reason ncolors's value is 0 so the fn
> always returns 0.

It also needs:

        if (color < G_num_standard_colors())
        {
                struct color_rgb col = G_standard_color_rgb(color);
                *r = col.r;
                *g = col.g;
                *b = col.b;
        }

These colours are stored in the table, but only when the first "r:g:b"
colour is added.

Alternatively, you could modify translate_or_add_color() to always
create the table, by removing the lines:

    preallocated = D_translate_color(lowerstr);
    if (preallocated)
        return preallocated;

-- 
Glynn Clements <[EMAIL PROTECTED]>
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to