add: width = width * 3;
context: renderMDGradient(unsigned width, unsigned height, RColor **colors, int count){    RImage *image, *tmp;    float a;    int i, offset, j;    unsigned char *ptr;    assert(count > 2);    if (width == 1)        return renderMVGradient(width, height, colors, count);    else if (height == 1)        return renderMHGradient(width, height, colors, count);    image = RCreateImage(width, height, False);    if (!image) {        return NULL;    }    if (count > width)        count = width;    if (count > height)        count = height;     if (count > 2)	tmp = renderMHGradient(2*width-1, 1, colors, count);    else	tmp = renderHGradient(2*width-1, 1, colors[0]->red<<8, 			      colors[0]->green<<8, colors[0]->blue<<8,			      colors[1]->red<<8, colors[1]->green<<8,			      colors[1]->blue<<8);    if (!tmp) {        RDestroyImage(image);        return NULL;    }    ptr = tmp->data;    a = ((float)(width - 1))/((float)(height - 1));    /* copy the first line to the other lines with corresponding offset */    for (i=0, j=0, offset=0; i<height; i++, j += width) {        offset = (int)(a*i+0.5)*3;	memcpy(&(image->data[j]), &ptr[offset], width);    }    RDestroyImage(tmp);    return image;}