Beispiel #1
0
/* BILINEAR INTERPOLATION */
void bilinear_interpolation_color(struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
{
	if (outF) {
		BLI_bilinear_interpolation_fl(in->rect_float, outF, in->x, in->y, 4, u, v);
	}
	else {
		BLI_bilinear_interpolation_char((unsigned char *) in->rect, outI, in->x, in->y, 4, u, v);
	}
}
void RenderLayersProg::doInterpolation(float output[4], float x, float y, PixelSampler sampler)
{
  unsigned int offset;
  int width = this->getWidth(), height = this->getHeight();

  int ix = x, iy = y;
  if (ix < 0 || iy < 0 || ix >= width || iy >= height) {
    if (this->m_elementsize == 1) {
      output[0] = 0.0f;
    }
    else if (this->m_elementsize == 3) {
      zero_v3(output);
    }
    else {
      zero_v4(output);
    }
    return;
  }

  switch (sampler) {
    case COM_PS_NEAREST: {
      offset = (iy * width + ix) * this->m_elementsize;

      if (this->m_elementsize == 1) {
        output[0] = this->m_inputBuffer[offset];
      }
      else if (this->m_elementsize == 3) {
        copy_v3_v3(output, &this->m_inputBuffer[offset]);
      }
      else {
        copy_v4_v4(output, &this->m_inputBuffer[offset]);
      }
      break;
    }

    case COM_PS_BILINEAR:
      BLI_bilinear_interpolation_fl(
          this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
      break;

    case COM_PS_BICUBIC:
      BLI_bicubic_interpolation_fl(
          this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
      break;
  }
}
void RenderLayersBaseProg::doInterpolation(float output[4], float x, float y, PixelSampler sampler)
{
	unsigned int offset;
	int ix, iy;
	int width = this->getWidth(), height = this->getHeight();

	switch (sampler) {
		case COM_PS_NEAREST:
			ix = x;
			iy = y;
			offset = (iy * width + ix) * this->m_elementsize;

			if (this->m_elementsize == 1)
				output[0] = this->m_inputBuffer[offset];
			else if (this->m_elementsize == 3)
				copy_v3_v3(output, &this->m_inputBuffer[offset]);
			else
				copy_v4_v4(output, &this->m_inputBuffer[offset]);

			break;

		case COM_PS_BILINEAR:
			BLI_bilinear_interpolation_fl(this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
			break;

		case COM_PS_BICUBIC:
			BLI_bicubic_interpolation_fl(this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
			break;
	}

	if (this->m_elementsize == 1) {
		output[1] = 0.0f;
		output[2] = 0.0f;
		output[3] = 0.0f;
	}
	else if (this->m_elementsize == 3) {
		output[3] = 1.0f;
	}
}