Ejemplo n.º 1
0
static struct ImBuf *make_vectorscope_view_from_ibuf_float(struct ImBuf * ibuf)
{
	struct ImBuf * rval = IMB_allocImBuf(515, 515, 32, IB_rect);
	int x,y;
	float* src = ibuf->rect_float;
	char* tgt = (char*) rval->rect;
	float rgb[3], yuv[3];
	int w = 515;
	int h = 515;
	float scope_gamma = 0.2;
	unsigned char wtable[256];

	for (x = 0; x < 256; x++) {
		wtable[x] = (unsigned char) (pow(((float) x + 1)/256, 
						 scope_gamma)*255);
	}

	for (x = 0; x <= 255; x++) {
		vectorscope_put_cross(255   ,     0,255 - x, tgt, w, h, 1);
		vectorscope_put_cross(255   ,     x,      0, tgt, w, h, 1);
		vectorscope_put_cross(255- x,   255,      0, tgt, w, h, 1);
		vectorscope_put_cross(0,        255,      x, tgt, w, h, 1);
		vectorscope_put_cross(0,    255 - x,    255, tgt, w, h, 1);
		vectorscope_put_cross(x,          0,    255, tgt, w, h, 1);
	}

	for (y = 0; y < ibuf->y; y++) {
		for (x = 0; x < ibuf->x; x++) {
			float * src1 = src + 4 * (ibuf->x * y + x);
			char * p;
			
			memcpy(rgb, src1, 3 * sizeof(float));

			CLAMP(rgb[0], 0.0f, 1.0f);
			CLAMP(rgb[1], 0.0f, 1.0f);
			CLAMP(rgb[2], 0.0f, 1.0f);

			rgb_to_yuv(rgb, yuv);
			
			p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) 
					   + (int) ((yuv[1] * (w - 3) + 1)));
			scope_put_pixel(wtable, (unsigned char*)p);
		}
	}

	vectorscope_put_cross(0, 0, 0, tgt, w, h, 3);

	return rval;
}
Ejemplo n.º 2
0
static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf)
{
	ImBuf *rval = IMB_allocImBuf(515, 515, 32, IB_rect);
	int x, y;
	char *src = (char *) ibuf->rect;
	char *tgt = (char *) rval->rect;
	float rgb[3], yuv[3];
	int w = 515;
	int h = 515;
	float scope_gamma = 0.2;
	unsigned char wtable[256];

	for (x = 0; x < 256; x++) {
		wtable[x] = (unsigned char) (pow(((float) x + 1) / 256,
		                                 scope_gamma) * 255);
	}

	for (x = 0; x <= 255; x++) {
		vectorscope_put_cross(255,     0, 255 - x, tgt, w, h, 1);
		vectorscope_put_cross(255,     x,      0, tgt, w, h, 1);
		vectorscope_put_cross(255 - x,   255,      0, tgt, w, h, 1);
		vectorscope_put_cross(0,        255,      x, tgt, w, h, 1);
		vectorscope_put_cross(0,    255 - x,    255, tgt, w, h, 1);
		vectorscope_put_cross(x,          0,    255, tgt, w, h, 1);
	}

	for (y = 0; y < ibuf->y; y++) {
		for (x = 0; x < ibuf->x; x++) {
			char *src1 = src + 4 * (ibuf->x * y + x);
			char *p;
			
			rgb[0] = (float)src1[0] / 255.0f;
			rgb[1] = (float)src1[1] / 255.0f;
			rgb[2] = (float)src1[2] / 255.0f;
			rgb_to_yuv_normalized(rgb, yuv);
			
			p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) 
			               + (int) ((yuv[1] * (w - 3) + 1)));
			scope_put_pixel(wtable, (unsigned char *)p);
		}
	}

	vectorscope_put_cross(0, 0, 0, tgt, w, h, 3);

	return rval;
}