rem: memcpy(&(image->data[i*width*3]), image->data, width*3);
add: memcpy(&(image->data[i*lineSize]), image->data, lineSize);
context: renderMHGradient(unsigned width, unsigned height, RColor **colors, int count){    int i, j, k;    unsigned long r, g, b, dr, dg, db;    RImage *image;    unsigned char *ptr;    unsigned width2;            assert(count > 2);        image = RCreateImage(width, height, False);    if (!image) {	return NULL;    }    ptr = image->data;        if (count > width)	count = width;        if (count > 1)        width2 = width/(count-1);    else        width2 = width;        k = 0;    r = colors[0]->red << 16;    g = colors[0]->green << 16;    b = colors[0]->blue << 16;    /* render the first line */    for (i=1; i<count; i++) {	dr = ((int)(colors[i]->red   - colors[i-1]->red)  <<16)/(int)width2;	dg = ((int)(colors[i]->green - colors[i-1]->green)<<16)/(int)width2;	db = ((int)(colors[i]->blue  - colors[i-1]->blue) <<16)/(int)width2;	for (j=0; j<width2; j++) {	    *ptr++ = (unsigned char)(r>>16);	    *ptr++ = (unsigned char)(g>>16);	    *ptr++ = (unsigned char)(b>>16);	    r += dr;	    g += dg;	    b += db;	    k++;	}	r = colors[i]->red << 16;	g = colors[i]->green << 16;	b = colors[i]->blue << 16;    }    for (j=k; j<width; j++) {	*ptr++ = (unsigned char)(r>>16);	*ptr++ = (unsigned char)(g>>16);	*ptr++ = (unsigned char)(b>>16);    }        /* copy the first line to the other lines */    for (i=1; i<height; i++) {	memcpy(&(image->data[i*width*3]), image->data, width*3);    }    return image;}