static void sampleImageAtLocation(ImBuf *ibuf, float x, float y, PixelSampler sampler, bool make_linear_rgb, float color[4])
{
	if (ibuf->rect_float) {
		switch (sampler) {
			case COM_PS_NEAREST:
				nearest_interpolation_color(ibuf, NULL, color, x, y);
				break;
			case COM_PS_BILINEAR:
				bilinear_interpolation_color(ibuf, NULL, color, x, y);
				break;
			case COM_PS_BICUBIC:
				bicubic_interpolation_color(ibuf, NULL, color, x, y);
				break;
		}
	}
	else {
		unsigned char byte_color[4];
		switch (sampler) {
			case COM_PS_NEAREST:
				nearest_interpolation_color(ibuf, byte_color, NULL, x, y);
				break;
			case COM_PS_BILINEAR:
				bilinear_interpolation_color(ibuf, byte_color, NULL, x, y);
				break;
			case COM_PS_BICUBIC:
				bicubic_interpolation_color(ibuf, byte_color, NULL, x, y);
				break;
		}
		rgba_uchar_to_float(color, byte_color);
		if (make_linear_rgb) {
			IMB_colormanagement_colorspace_to_scene_linear_v4(color, false, ibuf->rect_colorspace);
		}
	}
}
void MultilayerColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
	int yi = y;
	int xi = x;
	if (this->m_imageFloatBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) {
		zero_v4(output);
	}
	else {
		if (this->m_numberOfChannels == 4) {
			switch (sampler) {
				case COM_PS_NEAREST:
					nearest_interpolation_color(this->m_buffer, NULL, output, x, y);
					break;
				case COM_PS_BILINEAR:
					bilinear_interpolation_color(this->m_buffer, NULL, output, x, y);
					break;
				case COM_PS_BICUBIC:
					bicubic_interpolation_color(this->m_buffer, NULL, output, x, y);
					break;
			}
		}
		else {
			int offset = (yi * this->getWidth() + xi) * 3;
			copy_v3_v3(output, &this->m_imageFloatBuffer[offset]);
		}
	}
}
void MovieClipBaseOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
	ImBuf *ibuf = this->m_movieClipBuffer;

	if (ibuf == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) {
		zero_v4(output);
	}
	else if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
		/* Happens for multilayer exr, i.e. */
		zero_v4(output);
	}
	else {
		switch (sampler) {
			case COM_PS_NEAREST:
				nearest_interpolation_color(ibuf, NULL, output, x, y);
				break;
			case COM_PS_BILINEAR:
				bilinear_interpolation_color(ibuf, NULL, output, x, y);
				break;
			case COM_PS_BICUBIC:
				bicubic_interpolation_color(ibuf, NULL, output, x, y);
				break;
		}
	}
}
示例#4
0
void nearest_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, int yout)
{
	unsigned char *outI = NULL;
	float *outF = NULL;

	if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) {
		return;
	}

	pixel_from_buffer(out, &outI, &outF, xout, yout); /* gcc warns these could be uninitialized, but its ok */

	nearest_interpolation_color(in, outI, outF, x, y);
}