Beispiel #1
0
void Iwa_MotionBlurCompFx::setOutputRaster(float4 *srcMem, const RASTER dstRas,
                                           TDimensionI dim, int2 margin) {
  int out_j = 0;
  for (int j = margin.y; j < dstRas->getLy() + margin.y; j++, out_j++) {
    PIXEL *pix     = dstRas->pixels(out_j);
    float4 *chan_p = srcMem;
    chan_p += j * dim.lx + margin.x;
    for (int i = 0; i < dstRas->getLx(); i++) {
      float val;
      val    = (*chan_p).x * (float)PIXEL::maxChannelValue + 0.5f;
      pix->r = (typename PIXEL::Channel)((val > (float)PIXEL::maxChannelValue)
                                             ? (float)PIXEL::maxChannelValue
                                             : val);
      val    = (*chan_p).y * (float)PIXEL::maxChannelValue + 0.5f;
      pix->g = (typename PIXEL::Channel)((val > (float)PIXEL::maxChannelValue)
                                             ? (float)PIXEL::maxChannelValue
                                             : val);
      val    = (*chan_p).z * (float)PIXEL::maxChannelValue + 0.5f;
      pix->b = (typename PIXEL::Channel)((val > (float)PIXEL::maxChannelValue)
                                             ? (float)PIXEL::maxChannelValue
                                             : val);
      val    = (*chan_p).w * (float)PIXEL::maxChannelValue + 0.5f;
      pix->m = (typename PIXEL::Channel)((val > (float)PIXEL::maxChannelValue)
                                             ? (float)PIXEL::maxChannelValue
                                             : val);
      pix++;
      chan_p++;
    }
  }
}
void Iwa_GradientWarpFx::setSourceRaster(const RASTER srcRas,
										 float4 *dstMem,
										 TDimensionI dim)
{
	float4 *chann_p = dstMem;
	for (int j = 0; j < dim.ly; j++) {
		PIXEL *pix = srcRas->pixels(j);
		for (int i = 0; i < dim.lx; i++, pix++, chann_p++) {
			(*chann_p).x = (float)pix->r / (float)PIXEL::maxChannelValue;
			(*chann_p).y = (float)pix->g / (float)PIXEL::maxChannelValue;
			(*chann_p).z = (float)pix->b / (float)PIXEL::maxChannelValue;
			(*chann_p).w = (float)pix->m / (float)PIXEL::maxChannelValue;
		}
	}
}
void Iwa_GradientWarpFx::setWarperRaster(const RASTER warperRas,
										 float *dstMem,
										 TDimensionI dim)
{
	float *chann_p = dstMem;
	for (int j = 0; j < dim.ly; j++) {
		PIXEL *pix = warperRas->pixels(j);
		for (int i = 0; i < dim.lx; i++, pix++, chann_p++) {
			float r = (float)pix->r / (float)PIXEL::maxChannelValue;
			float g = (float)pix->g / (float)PIXEL::maxChannelValue;
			float b = (float)pix->b / (float)PIXEL::maxChannelValue;

			(*chann_p) = 0.298912f * r + 0.586611f * g + 0.114478f * b;
		}
	}
}
Beispiel #4
0
bool Iwa_MotionBlurCompFx::setSourceRaster(const RASTER srcRas, float4 *dstMem,
                                           TDimensionI dim,
                                           PremultiTypes type) {
  bool isPremultiplied = (type == SOURCE_IS_NOT_PREMUTIPLIED) ? false : true;

  float4 *chann_p = dstMem;

  float threshold = 100.0 / (float)TPixel64::maxChannelValue;

  int max = 0;
  for (int j = 0; j < dim.ly; j++) {
    PIXEL *pix = srcRas->pixels(j);
    for (int i = 0; i < dim.lx; i++) {
      (*chann_p).x = (float)pix->r / (float)PIXEL::maxChannelValue;
      (*chann_p).y = (float)pix->g / (float)PIXEL::maxChannelValue;
      (*chann_p).z = (float)pix->b / (float)PIXEL::maxChannelValue;
      (*chann_p).w = (float)pix->m / (float)PIXEL::maxChannelValue;

      /*- RGB値がアルファチャンネルより大きいピクセルがあれば、
              Premutiplyされていないと判断する -*/
      if (type == AUTO && isPremultiplied &&
          (((*chann_p).x > (*chann_p).w && (*chann_p).x > threshold) ||
           ((*chann_p).y > (*chann_p).w && (*chann_p).y > threshold) ||
           ((*chann_p).z > (*chann_p).w && (*chann_p).z > threshold)))
        isPremultiplied = false;

      pix++;
      chann_p++;
    }
  }

  if (isPremultiplied) {
    chann_p = dstMem;
    for (int i = 0; i < dim.lx * dim.ly; i++, chann_p++) {
      if ((*chann_p).x > (*chann_p).w) (*chann_p).x = (*chann_p).w;
      if ((*chann_p).y > (*chann_p).w) (*chann_p).y = (*chann_p).w;
      if ((*chann_p).z > (*chann_p).w) (*chann_p).z = (*chann_p).w;
    }
  }

  return isPremultiplied;
}