当前位置: 首页>>代码示例>>C++>>正文


C++ FTOCHAR函数代码示例

本文整理汇总了C++中FTOCHAR函数的典型用法代码示例。如果您正苦于以下问题:C++ FTOCHAR函数的具体用法?C++ FTOCHAR怎么用?C++ FTOCHAR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了FTOCHAR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: draw_zebra_float

static void draw_zebra_float(ImBuf *src, ImBuf *ibuf, float perc)
{
	float limit = perc / 100.0f;
	const float *p = src->rect_float;
	unsigned char *o = (unsigned char *) ibuf->rect;
	int x;
	int y;

	for (y = 0; y < ibuf->y; y++) {
		for (x = 0; x < ibuf->x; x++) {
			float r = *p++;
			float g = *p++;
			float b = *p++;
			float a = *p++;

			if (r >= limit || g >= limit || b >= limit) {
				if (((x + y) & 0x08) != 0) {
					r = -r;
					g = -g;
					b = -b;
				}
			}

			*o++ = FTOCHAR(r);
			*o++ = FTOCHAR(g);
			*o++ = FTOCHAR(b);
			*o++ = FTOCHAR(a);
		}
	}
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:30,代码来源:sequencer_scopes.c

示例2: norm

/* MultiresBake callback for normals' baking
   general idea:
     - find coord and normal of point with specified UV in hi-res mesh
     - multiply it by tangmat
     - vector in color space would be norm(vec) /2 + (0.5, 0.5, 0.5) */
static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, const void *UNUSED(bake_data),
                                   const int face_index, const int lvl, const float st[2],
                                   float tangmat[3][3], const int x, const int y)
{
	MTFace *mtface= CustomData_get_layer(&lores_dm->faceData, CD_MTFACE);
	MFace mface;
	Image *ima= mtface[face_index].tpage;
	ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
	float uv[2], *st0, *st1, *st2, *st3;
	int pixel= ibuf->x*y + x;
	float n[3], vec[3], tmp[3]= {0.5, 0.5, 0.5};

	lores_dm->getFace(lores_dm, face_index, &mface);

	st0= mtface[face_index].uv[0];
	st1= mtface[face_index].uv[1];
	st2= mtface[face_index].uv[2];

	if(mface.v4) {
		st3= mtface[face_index].uv[3];
		resolve_quad_uv(uv, st, st0, st1, st2, st3);
	} else
		resolve_tri_uv(uv, st, st0, st1, st2);

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

	get_ccgdm_data(lores_dm, hires_dm, lvl, face_index, uv[0], uv[1], NULL, n);

	mul_v3_m3v3(vec, tangmat, n);
	normalize_v3(vec);
	mul_v3_fl(vec, 0.5);
	add_v3_v3(vec, tmp);

	if(ibuf->rect_float) {
		float *rrgbf= ibuf->rect_float + pixel*4;
		rrgbf[0]= vec[0];
		rrgbf[1]= vec[1];
		rrgbf[2]= vec[2];
		rrgbf[3]= 1.0f;

		ibuf->userflags= IB_RECT_INVALID;
	} else {
		char *rrgb= (char*)ibuf->rect + pixel*4;
		rrgb[0]= FTOCHAR(vec[0]);
		rrgb[1]= FTOCHAR(vec[1]);
		rrgb[2]= FTOCHAR(vec[2]);
		rrgb[3]= 255;
	}
}
开发者ID:BHCLL,项目名称:blendocv,代码行数:55,代码来源:object_bake.c

示例3: curvemapping_evaluate_premulRGB

/* same as above, byte version */
void curvemapping_evaluate_premulRGB(const CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3])
{
	float vecin[3], vecout[3];

	vecin[0] = (float) vecin_byte[0] / 255.0f;
	vecin[1] = (float) vecin_byte[1] / 255.0f;
	vecin[2] = (float) vecin_byte[2] / 255.0f;

	curvemapping_evaluate_premulRGBF(cumap, vecout, vecin);

	vecout_byte[0] = FTOCHAR(vecout[0]);
	vecout_byte[1] = FTOCHAR(vecout[1]);
	vecout_byte[2] = FTOCHAR(vecout[2]);
}
开发者ID:scorpion81,项目名称:blender-voro,代码行数:15,代码来源:colortools.c

示例4: apply_heights_data

static void apply_heights_data(void *bake_data)
{
	MHeightBakeData *height_data= (MHeightBakeData*)bake_data;
	ImBuf *ibuf= BKE_image_get_ibuf(height_data->ima, NULL);
	int x, y, i;
	float height, *heights= height_data->heights;
	float min= height_data->height_min, max= height_data->height_max;

	for(x= 0; x<ibuf->x; x++) {
		for(y =0; y<ibuf->y; y++) {
			i= ibuf->x*y + x;

			if(((char*)ibuf->userdata)[i] != FILTER_MASK_USED)
				continue;

			if(ibuf->rect_float) {
				float *rrgbf= ibuf->rect_float + i*4;

				if(max-min > 1e-5f) height= (heights[i]-min)/(max-min);
				else height= 0;

				rrgbf[0]=rrgbf[1]=rrgbf[2]= height;
			} else {
				char *rrgb= (char*)ibuf->rect + i*4;

				if(max-min > 1e-5f) height= (heights[i]-min)/(max-min);
				else height= 0;

				rrgb[0]=rrgb[1]=rrgb[2]= FTOCHAR(height);
			}
		}
	}

	ibuf->userflags= IB_RECT_INVALID;
}
开发者ID:ryden,项目名称:blender-mirror,代码行数:35,代码来源:object_bake.c

示例5: rna_Image_pixels_set

static void rna_Image_pixels_set(PointerRNA *ptr, const float *values)
{
	Image *ima = ptr->id.data;
	ImBuf *ibuf;
	void *lock;
	int i, size;

	ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);

	if (ibuf) {
		size = ibuf->x * ibuf->y * ibuf->channels;

		if (ibuf->rect_float) {
			memcpy(ibuf->rect_float, values, sizeof(float) * size);
		}
		else {
			for (i = 0; i < size; i++)
				((unsigned char *)ibuf->rect)[i] = FTOCHAR(values[i]);
		}

		ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
	}

	BKE_image_release_ibuf(ima, ibuf, lock);
}
开发者ID:silkentrance,项目名称:blender,代码行数:25,代码来源:rna_image.c

示例6: float_to_byte_dither_v4

MINLINE void float_to_byte_dither_v4(uchar b[4], const float f[4], DitherContext *di, float s, float t)
{
	float dither_value = dither_random_value(s, t) * 0.005f * di->dither;

	b[0] = ftochar(dither_value + f[0]);
	b[1] = ftochar(dither_value + f[1]);
	b[2] = ftochar(dither_value + f[2]);
	b[3] = FTOCHAR(f[3]);
}
开发者ID:linkedinyou,项目名称:blender-git,代码行数:9,代码来源:divers.c

示例7: IMB_colormanagement_get_luminance_byte

/* Byte equivalent of IMB_colormanagement_get_luminance(). */
unsigned char IMB_colormanagement_get_luminance_byte(const unsigned char rgb[3])
{
	float rgbf[3];
	float val;

	rgb_uchar_to_float(rgbf, rgb);
	val = dot_v3v3(imbuf_luma_coefficients, rgbf);

	return FTOCHAR(val);
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:11,代码来源:colormanagement_inline.c

示例8: switch

void VCOLDataWrapper::get_vcol(int v_index, MLoopCol *mloopcol)
{
	int stride = mVData->getStride(0);
	if (stride == 0) stride = 3;

	switch (mVData->getType()) {
		case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
		{
			COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
			if (values->empty() || values->getCount() <= (v_index * stride + 2)) return;  // xxx need to create an eror instead

			mloopcol->r = FTOCHAR((*values)[v_index * stride]);
			mloopcol->g = FTOCHAR((*values)[v_index * stride + 1]);
			mloopcol->b = FTOCHAR((*values)[v_index * stride + 2]);
		}
		break;

		case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
		{
			COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
			if (values->empty() || values->getCount() <= (v_index * stride + 2)) return; // xxx need to create an eror instead

			mloopcol->r = FTOCHAR((*values)[v_index * stride]);
			mloopcol->g = FTOCHAR((*values)[v_index * stride + 1]);
			mloopcol->b = FTOCHAR((*values)[v_index * stride + 2]);
		}
		break;
		default:
			fprintf(stderr, "VCOLDataWrapper.getvcol(): unknown data type\n");
	}

}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:32,代码来源:MeshImporter.cpp

示例9: MEM_callocN

static unsigned char *GPU_texture_convert_pixels(int length, const float *fpixels)
{
	unsigned char *pixels, *p;
	const float *fp = fpixels;
	const int len = 4 * length;

	p = pixels = MEM_callocN(sizeof(unsigned char) * len, "GPUTexturePixels");

	for (int a = 0; a < len; a++, p++, fp++)
		*p = FTOCHAR((*fp));

	return pixels;
}
开发者ID:GameLemur,项目名称:blender,代码行数:13,代码来源:gpu_texture.c

示例10: lockMutex

void *AntiAliasOperation::initializeTileData(rcti *rect)
{
	if (this->m_buffer) { return this->m_buffer; }
	lockMutex();
	if (this->m_buffer == NULL) {
		MemoryBuffer *tile = (MemoryBuffer *)this->m_valueReader->initializeTileData(rect);
		int size = tile->getHeight() * tile->getWidth();
		float *input = tile->getBuffer();
		char *valuebuffer = (char *)MEM_mallocN(sizeof(char) * size, __func__);
		for (int i = 0; i < size; i++) {
			float in = input[i * COM_NUMBER_OF_CHANNELS];
			valuebuffer[i] = FTOCHAR(in);
		}
		antialias_tagbuf(tile->getWidth(), tile->getHeight(), valuebuffer);
		this->m_buffer = valuebuffer;
	}
	unlockMutex();
	return this->m_buffer;
}
开发者ID:BlueLabelStudio,项目名称:blender,代码行数:19,代码来源:COM_AntiAliasOperation.cpp

示例11: rna_ImagePreview_pixels_float_set

static void rna_ImagePreview_pixels_float_set(PointerRNA *ptr, const float *values, enum eIconSizes size)
{
	ID *id = ptr->id.data;
	PreviewImage *prv_img = (PreviewImage *)ptr->data;

	unsigned char *data = (unsigned char *)prv_img->rect[size];
	const size_t len = prv_img->w[size] * prv_img->h[size] * 4;
	size_t i;

	BLI_assert(sizeof(unsigned int) == 4);

	if (id != NULL) {
		BLI_assert(prv_img == BKE_previewimg_id_ensure(id));
	}

	for (i = 0; i < len; i++) {
		data[i] = FTOCHAR(values[i]);
	}
	prv_img->flag[size] |= PRV_USER_EDITED;
}
开发者ID:pawkoz,项目名称:dyplom,代码行数:20,代码来源:rna_ID.c

示例12: IMB_colormanagement_display_get_named

/* create imbuf with brush color */
static ImBuf *brush_painter_imbuf_new(BrushPainter *painter, int size, float pressure, float distance)
{
	Scene *scene = painter->scene;
	Brush *brush = painter->brush;

	const char *display_device = scene->display_settings.display_device;
	struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);

	rctf tex_mapping = painter->tex_mapping;
	struct ImagePool *pool = painter->pool;

	bool use_color_correction = painter->cache.use_color_correction;
	bool use_float = painter->cache.use_float;
	bool is_texbrush = painter->cache.is_texbrush;

	int x, y, thread = 0;
	float brush_rgb[3];

	/* allocate image buffer */
	ImBuf *ibuf = IMB_allocImBuf(size, size, 32, (use_float) ? IB_rectfloat : IB_rect);

	/* get brush color */
	if (brush->imagepaint_tool == PAINT_TOOL_DRAW) {
		paint_brush_color_get(scene, brush, use_color_correction, painter->cache.invert, distance, pressure, brush_rgb, display);
	}
	else {
		brush_rgb[0] = 1.0f;
		brush_rgb[1] = 1.0f;
		brush_rgb[2] = 1.0f;
	}

	/* fill image buffer */
	for (y = 0; y < size; y++) {
		for (x = 0; x < size; x++) {
			/* sample texture and multiply with brush color */
			float texco[3], rgba[4];

			if (is_texbrush) {
				brush_imbuf_tex_co(&tex_mapping, x, y, texco);
				BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
				/* TODO(sergey): Support texture paint color space. */
				if (!use_float) {
					IMB_colormanagement_scene_linear_to_display_v3(rgba, display);
				}
				mul_v3_v3(rgba, brush_rgb);
			}
			else {
				copy_v3_v3(rgba, brush_rgb);
				rgba[3] = 1.0f;
			}

			if (use_float) {
				/* write to float pixel */
				float *dstf = ibuf->rect_float + (y * size + x) * 4;
				mul_v3_v3fl(dstf, rgba, rgba[3]); /* premultiply */
				dstf[3] = rgba[3];
			}
			else {
				/* write to byte pixel */
				unsigned char *dst = (unsigned char *)ibuf->rect + (y * size + x) * 4;

				rgb_float_to_uchar(dst, rgba);
				dst[3] = FTOCHAR(rgba[3]);
			}
		}
	}

	return ibuf;
}
开发者ID:DrangPo,项目名称:blender,代码行数:70,代码来源:paint_image_2d.c

示例13: IMB_buffer_byte_from_float

/* float to byte pixels, output 4-channel RGBA */
void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
                                int channels_from, float dither, int profile_to, int profile_from, bool predivide,
                                int width, int height, int stride_to, int stride_from)
{
	float tmp[4];
	int x, y;
	DitherContext *di = NULL;
	float inv_width = 1.0f / width,
	      inv_height = 1.0f / height;

	/* we need valid profiles */
	BLI_assert(profile_to != IB_PROFILE_NONE);
	BLI_assert(profile_from != IB_PROFILE_NONE);

	if (dither)
		di = create_dither_context(dither);

	for (y = 0; y < height; y++) {
		float t = y * inv_height;

		if (channels_from == 1) {
			/* single channel input */
			const float *from = rect_from + stride_from * y;
			uchar *to = rect_to + stride_to * y * 4;

			for (x = 0; x < width; x++, from++, to += 4)
				to[0] = to[1] = to[2] = to[3] = FTOCHAR(from[0]);
		}
		else if (channels_from == 3) {
			/* RGB input */
			const float *from = rect_from + stride_from * y * 3;
			uchar *to = rect_to + stride_to * y * 4;

			if (profile_to == profile_from) {
				/* no color space conversion */
				for (x = 0; x < width; x++, from += 3, to += 4) {
					rgb_float_to_uchar(to, from);
					to[3] = 255;
				}
			}
			else if (profile_to == IB_PROFILE_SRGB) {
				/* convert from linear to sRGB */
				for (x = 0; x < width; x++, from += 3, to += 4) {
					linearrgb_to_srgb_v3_v3(tmp, from);
					rgb_float_to_uchar(to, tmp);
					to[3] = 255;
				}
			}
			else if (profile_to == IB_PROFILE_LINEAR_RGB) {
				/* convert from sRGB to linear */
				for (x = 0; x < width; x++, from += 3, to += 4) {
					srgb_to_linearrgb_v3_v3(tmp, from);
					rgb_float_to_uchar(to, tmp);
					to[3] = 255;
				}
			}
		}
		else if (channels_from == 4) {
			/* RGBA input */
			const float *from = rect_from + stride_from * y * 4;
			uchar *to = rect_to + stride_to * y * 4;

			if (profile_to == profile_from) {
				float straight[4];

				/* no color space conversion */
				if (dither && predivide) {
					for (x = 0; x < width; x++, from += 4, to += 4) {
						premul_to_straight_v4_v4(straight, from);
						float_to_byte_dither_v4(to, straight, di, (float) x * inv_width, t);
					}
				}
				else if (dither) {
					for (x = 0; x < width; x++, from += 4, to += 4)
						float_to_byte_dither_v4(to, from, di, (float) x * inv_width, t);
				}
				else if (predivide) {
					for (x = 0; x < width; x++, from += 4, to += 4) {
						premul_to_straight_v4_v4(straight, from);
						rgba_float_to_uchar(to, straight);
					}
				}
				else {
					for (x = 0; x < width; x++, from += 4, to += 4)
						rgba_float_to_uchar(to, from);
				}
			}
			else if (profile_to == IB_PROFILE_SRGB) {
				/* convert from linear to sRGB */
				unsigned short us[4];
				float straight[4];

				if (dither && predivide) {
					for (x = 0; x < width; x++, from += 4, to += 4) {
						premul_to_straight_v4_v4(straight, from);
						linearrgb_to_srgb_ushort4(us, from);
						ushort_to_byte_dither_v4(to, us, di, (float) x * inv_width, t);
					}
				}
//.........这里部分代码省略.........
开发者ID:linkedinyou,项目名称:blender-git,代码行数:101,代码来源:divers.c

示例14: image_buffer_rect_update

/* called inside thread! */
void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volatile rcti *renrect)
{
	float x1, y1, *rectf= NULL;
	int ymin, ymax, xmin, xmax;
	int rymin, rxmin, do_color_management;
	char *rectc;

	/* if renrect argument, we only refresh scanlines */
	if(renrect) {
		/* if ymax==recty, rendering of layer is ready, we should not draw, other things happen... */
		if(rr->renlay==NULL || renrect->ymax>=rr->recty)
			return;

		/* xmin here is first subrect x coord, xmax defines subrect width */
		xmin = renrect->xmin + rr->crop;
		xmax = renrect->xmax - xmin + rr->crop;
		if(xmax<2)
			return;

		ymin= renrect->ymin + rr->crop;
		ymax= renrect->ymax - ymin + rr->crop;
		if(ymax<2)
			return;
		renrect->ymin= renrect->ymax;

	}
	else {
		xmin = ymin = rr->crop;
		xmax = rr->rectx - 2*rr->crop;
		ymax = rr->recty - 2*rr->crop;
	}

	/* xmin ymin is in tile coords. transform to ibuf */
	rxmin= rr->tilerect.xmin + xmin;
	if(rxmin >= ibuf->x) return;
	rymin= rr->tilerect.ymin + ymin;
	if(rymin >= ibuf->y) return;

	if(rxmin + xmax > ibuf->x)
		xmax= ibuf->x - rxmin;
	if(rymin + ymax > ibuf->y)
		ymax= ibuf->y - rymin;

	if(xmax < 1 || ymax < 1) return;

	/* find current float rect for display, first case is after composit... still weak */
	if(rr->rectf)
		rectf= rr->rectf;
	else {
		if(rr->rect32)
			return;
		else {
			if(rr->renlay==NULL || rr->renlay->rectf==NULL) return;
			rectf= rr->renlay->rectf;
		}
	}
	if(rectf==NULL) return;

	if(ibuf->rect==NULL)
		imb_addrectImBuf(ibuf);
	
	rectf+= 4*(rr->rectx*ymin + xmin);
	rectc= (char *)(ibuf->rect + ibuf->x*rymin + rxmin);

	do_color_management = (scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT));
	
	/* XXX make nice consistent functions for this */
	for(y1= 0; y1<ymax; y1++) {
		float *rf= rectf;
		float srgb[3];
		char *rc= rectc;
		const float dither = ibuf->dither / 255.0f;

		/* XXX temp. because crop offset */
		if(rectc >= (char *)(ibuf->rect)) {
			for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
				/* color management */
				if(do_color_management) {
					srgb[0]= linearrgb_to_srgb(rf[0]);
					srgb[1]= linearrgb_to_srgb(rf[1]);
					srgb[2]= linearrgb_to_srgb(rf[2]);
				}
				else {
					copy_v3_v3(srgb, rf);
				}

				/* dither */
				if(dither != 0.0f) {
					const float d = (BLI_frand()-0.5f)*dither;

					srgb[0] += d;
					srgb[1] += d;
					srgb[2] += d;
				}

				/* write */
				rc[0]= FTOCHAR(srgb[0]);
				rc[1]= FTOCHAR(srgb[1]);
				rc[2]= FTOCHAR(srgb[2]);
//.........这里部分代码省略.........
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:101,代码来源:render_internal.c

示例15: IMB_buffer_byte_from_float_mask

/* float to byte pixels, output 4-channel RGBA */
void IMB_buffer_byte_from_float_mask(uchar *rect_to, const float *rect_from,
                                int channels_from, float dither, bool predivide,
                                int width, int height, int stride_to, int stride_from, char *mask)
{
	int x, y;
	DitherContext *di = NULL;
	float inv_width = 1.0f / width,
	inv_height = 1.0f / height;

	if (dither)
		di = create_dither_context(dither);

	for (y = 0; y < height; y++) {
		float t = y * inv_height;

		if (channels_from == 1) {
			/* single channel input */
			const float *from = rect_from + stride_from * y;
			uchar *to = rect_to + stride_to * y * 4;

			for (x = 0; x < width; x++, from++, to += 4)
				if (*mask++ == FILTER_MASK_USED)
					to[0] = to[1] = to[2] = to[3] = FTOCHAR(from[0]);
		}
		else if (channels_from == 3) {
			/* RGB input */
			const float *from = rect_from + stride_from * y * 3;
			uchar *to = rect_to + stride_to * y * 4;

			for (x = 0; x < width; x++, from += 3, to += 4) {
				if (*mask++ == FILTER_MASK_USED) {
					rgb_float_to_uchar(to, from);
					to[3] = 255;
				}
			}
		}
		else if (channels_from == 4) {
			/* RGBA input */
			const float *from = rect_from + stride_from * y * 4;
			uchar *to = rect_to + stride_to * y * 4;

			float straight[4];

			if (dither && predivide) {
				for (x = 0; x < width; x++, from += 4, to += 4) {
					if (*mask++ == FILTER_MASK_USED) {
						premul_to_straight_v4_v4(straight, from);
						float_to_byte_dither_v4(to, straight, di, (float) x * inv_width, t);
					}
				}
			}
			else if (dither) {
				for (x = 0; x < width; x++, from += 4, to += 4)
					if (*mask++ == FILTER_MASK_USED)
						float_to_byte_dither_v4(to, from, di, (float) x * inv_width, t);
			}
			else if (predivide) {
				for (x = 0; x < width; x++, from += 4, to += 4) {
					if (*mask++ == FILTER_MASK_USED) {
						premul_to_straight_v4_v4(straight, from);
						rgba_float_to_uchar(to, straight);
					}
				}
			}
			else {
				for (x = 0; x < width; x++, from += 4, to += 4)
					if (*mask++ == FILTER_MASK_USED)
						rgba_float_to_uchar(to, from);
			}
		}
	}

	if (dither)
		clear_dither_context(di);
}
开发者ID:linkedinyou,项目名称:blender-git,代码行数:76,代码来源:divers.c


注:本文中的FTOCHAR函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。