All pastes #294444 Raw Edit

Anonymous

public text v1 · immutable
#294444 ·published 2006-12-28 14:06 UTC
rendered paste body
static Bool bgraToRGB(char *source, JSAMPLE **dest, int height, int width, int stride)
{
	int h, w;
	int ps = stride / width;    /* pixel size */
	JSAMPLE *d;

	d = malloc(height*width*3*sizeof(JSAMPLE));
	if (!d)
		return FALSE;

	*dest = d;

	for (h = height - 1; h >= 0; h--)
		for (w = 0; w < width; w++)
		{
			d[((h * width + w) * 3) + 0] = source[((h * width + w) * ps) + 0];//R
			d[((h * width + w) * 3) + 1] = source[((h * width + w) * ps) + 1];//G
			d[((h * width + w) * 3) + 2] = source[((h * width + w) * ps) + 2];//B
		}

	return TRUE;
}