public void generate(out RGBA_Bytes destPixel, int x, int y)
{
base.interpolator().begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), 1);
int* fg = stackalloc int[4];
byte* fg_ptr;
IImage imageSource = base.source().DestImage;
int maxx = (int)imageSource.Width() - 1;
int maxy = (int)imageSource.Height() - 1;
ISpanInterpolator spanInterpolator = base.interpolator();
unchecked
{
int x_hr;
int y_hr;
spanInterpolator.coordinates(out x_hr, out y_hr);
x_hr -= base.filter_dx_int();
y_hr -= base.filter_dy_int();
int x_lr = x_hr >> (int)image_subpixel_scale_e.image_subpixel_shift;
int y_lr = y_hr >> (int)image_subpixel_scale_e.image_subpixel_shift;
int weight;
fg[0] = fg[1] = fg[2] = fg[3] = (int)image_subpixel_scale_e.image_subpixel_scale * (int)image_subpixel_scale_e.image_subpixel_scale / 2;
x_hr &= (int)image_subpixel_scale_e.image_subpixel_mask;
y_hr &= (int)image_subpixel_scale_e.image_subpixel_mask;
fg_ptr = imageSource.GetPixelPointerY(y_lr) + (x_lr * 4);
weight = (int)(((int)image_subpixel_scale_e.image_subpixel_scale - x_hr) *
((int)image_subpixel_scale_e.image_subpixel_scale - y_hr));
fg[0] += weight * fg_ptr[0];
fg[1] += weight * fg_ptr[1];
fg[2] += weight * fg_ptr[2];
fg[3] += weight * fg_ptr[3];
weight = (int)(x_hr * ((int)image_subpixel_scale_e.image_subpixel_scale - y_hr));
fg[0] += weight * fg_ptr[4];
fg[1] += weight * fg_ptr[5];
fg[2] += weight * fg_ptr[6];
fg[3] += weight * fg_ptr[7];
++y_lr;
fg_ptr = imageSource.GetPixelPointerY(y_lr) + (x_lr * 4);
weight = (int)(((int)image_subpixel_scale_e.image_subpixel_scale - x_hr) * y_hr);
fg[0] += weight * fg_ptr[0];
fg[1] += weight * fg_ptr[1];
fg[2] += weight * fg_ptr[2];
fg[3] += weight * fg_ptr[3];
weight = (int)(x_hr * y_hr);
fg[0] += weight * fg_ptr[4];
fg[1] += weight * fg_ptr[5];
fg[2] += weight * fg_ptr[6];
fg[3] += weight * fg_ptr[7];
fg[0] >>= (int)image_subpixel_scale_e.image_subpixel_shift * 2;
fg[1] >>= (int)image_subpixel_scale_e.image_subpixel_shift * 2;
fg[2] >>= (int)image_subpixel_scale_e.image_subpixel_shift * 2;
fg[3] >>= (int)image_subpixel_scale_e.image_subpixel_shift * 2;
destPixel.m_R = (byte)fg[OrderR];
destPixel.m_G = (byte)fg[OrderG];
destPixel.m_B = (byte)fg[ImageBuffer.OrderB];
destPixel.m_A = (byte)fg[OrderA];
}
}
#endif