public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len) { RasterBuffer pSourceRenderingBuffer = base.Source().PixelFormat.GetRenderingBuffer(); ISpanInterpolator <T> spanInterpolator = base.Interpolator; spanInterpolator.Begin(M.New <T>(x).Add(base.FilterDxDbl()), M.New <T>(y).Add(base.FilterDyDbl()), len); do { int x_hr; int y_hr; spanInterpolator.Coordinates(out x_hr, out y_hr); int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift; int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift; byte *fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2); //byte* fg_ptr = spanInterpolator.span(x_lr, y_lr, 1); //(*span).R = fg_ptr[OrderR]; //(*span).G = fg_ptr[OrderG]; //(*span).B = fg_ptr[OrderB]; //(*span).A = fg_ptr[OrderA]; (*span) = new RGBA_Bytes(fg_ptr[OrderR], fg_ptr[OrderG], fg_ptr[OrderB], fg_ptr[OrderA]); ++span; spanInterpolator.Next(); } while (--len != 0); }
//-------------------------------------------------------------------- public unsafe void Generate(RGBA_Bytes *span, int x, int y, uint len) { int dd = m_d2 - m_d1; if (dd < 1) { dd = 1; } m_interpolator.Begin(x + 0.5, y + 0.5, len); do { m_interpolator.Coordinates(out x, out y); int d = m_gradient_function.Calculate(x >> downscale_shift, y >> downscale_shift, m_d2); d = ((d - m_d1) * (int)m_color_function.Size) / dd; if (d < 0) { d = 0; } if (d >= (int)m_color_function.Size) { d = m_color_function.Size - 1; } *span++ = m_color_function[d]; m_interpolator.Next(); }while(--len != 0); }
public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len) { RasterBuffer pSourceRenderingBuffer = base.source().PixelFormat.RenderingBuffer; ISpanInterpolator spanInterpolator = base.interpolator(); spanInterpolator.Begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), len); do { int x_hr; int y_hr; spanInterpolator.Coordinates(out x_hr, out y_hr); int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift; int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift; byte *fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2); //byte* fg_ptr = spanInterpolator.Span(x_lr, y_lr, 1); (*span).m_R = fg_ptr[OrderR]; (*span).m_G = fg_ptr[OrderG]; (*span).m_B = fg_ptr[OrderB]; (*span).m_A = fg_ptr[OrderA]; ++span; spanInterpolator.Next(); } while(--len != 0); }
public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len) { #if use_timers Generate_Span.Start(); #endif base.interpolator().Begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), len); //uint[] fg = new uint[4]; uint *fg = stackalloc uint[4]; uint back_r = m_back_color.m_R; uint back_g = m_back_color.m_G; uint back_b = m_back_color.m_B; uint back_a = m_back_color.m_A; byte *fg_ptr; RasterBuffer pSourceRenderingBuffer = base.source().PixelFormat.RenderingBuffer; int maxx = (int)pSourceRenderingBuffer.Width() - 1; int maxy = (int)pSourceRenderingBuffer.Height() - 1; ISpanInterpolator spanInterpolator = base.interpolator(); unchecked { do { 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.Shift; int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift; uint weight; if (x_lr >= 0 && y_lr >= 0 && x_lr < maxx && y_lr < maxy) { fg[0] = fg[1] = fg[2] = fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2; x_hr &= (int)image_subpixel_scale_e.Mask; y_hr &= (int)image_subpixel_scale_e.Mask; fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2); weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * ((int)image_subpixel_scale_e.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 = (uint)(x_hr * ((int)image_subpixel_scale_e.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 = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2); weight = (uint)(((int)image_subpixel_scale_e.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 = (uint)(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.Shift * 2; fg[1] >>= (int)image_subpixel_scale_e.Shift * 2; fg[2] >>= (int)image_subpixel_scale_e.Shift * 2; fg[3] >>= (int)image_subpixel_scale_e.Shift * 2; } else { if (x_lr < -1 || y_lr < -1 || x_lr > maxx || y_lr > maxy) { fg[OrderR] = back_r; fg[OrderG] = back_g; fg[OrderB] = back_b; fg[OrderA] = back_a; } else { fg[0] = fg[1] = fg[2] = fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2; x_hr &= (int)image_subpixel_scale_e.Mask; y_hr &= (int)image_subpixel_scale_e.Mask; weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * ((int)image_subpixel_scale_e.Scale - y_hr)); BlendInFilterPixel(fg, back_r, back_g, back_b, back_a, pSourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight); x_lr++; weight = (uint)(x_hr * ((int)image_subpixel_scale_e.Scale - y_hr)); BlendInFilterPixel(fg, back_r, back_g, back_b, back_a, pSourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight); x_lr--; y_lr++; weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * y_hr); BlendInFilterPixel(fg, back_r, back_g, back_b, back_a, pSourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight); x_lr++; weight = (uint)(x_hr * y_hr); BlendInFilterPixel(fg, back_r, back_g, back_b, back_a, pSourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight); fg[0] >>= (int)image_subpixel_scale_e.Shift * 2; fg[1] >>= (int)image_subpixel_scale_e.Shift * 2; fg[2] >>= (int)image_subpixel_scale_e.Shift * 2; fg[3] >>= (int)image_subpixel_scale_e.Shift * 2; } } (*span).m_R = (byte)fg[0]; (*span).m_G = (byte)fg[1]; (*span).m_B = (byte)fg[2]; (*span).m_A = (byte)fg[3]; ++span; spanInterpolator.Next(); } while (--len != 0); } #if use_timers Generate_Span.Stop(); #endif }
public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len) { #if use_timers Generate_Span.Start(); #endif base.interpolator().Begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), len); uint *fg = stackalloc uint[4]; byte *fg_ptr; RasterBuffer pSourceRenderingBuffer = base.source().PixelFormat.RenderingBuffer; int maxx = (int)pSourceRenderingBuffer.Width() - 1; int maxy = (int)pSourceRenderingBuffer.Height() - 1; ISpanInterpolator spanInterpolator = base.interpolator(); unchecked { do { 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.Shift; int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift; uint weight; fg[0] = fg[1] = fg[2] = fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2; x_hr &= (int)image_subpixel_scale_e.Mask; y_hr &= (int)image_subpixel_scale_e.Mask; fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2); weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * ((int)image_subpixel_scale_e.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 = (uint)(x_hr * ((int)image_subpixel_scale_e.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 = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2); weight = (uint)(((int)image_subpixel_scale_e.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 = (uint)(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.Shift * 2; fg[1] >>= (int)image_subpixel_scale_e.Shift * 2; fg[2] >>= (int)image_subpixel_scale_e.Shift * 2; fg[3] >>= (int)image_subpixel_scale_e.Shift * 2; (*span).m_R = (byte)fg[OrderR]; (*span).m_G = (byte)fg[OrderG]; (*span).m_B = (byte)fg[OrderB]; (*span).m_A = (byte)fg[OrderA]; ++span; spanInterpolator.Next(); } while (--len != 0); } #if use_timers Generate_Span.Stop(); #endif }
//-------------------------------------------------------------------- public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len) { ISpanInterpolator spanInterpolator = base.interpolator(); spanInterpolator.Begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), len); int *fg = stackalloc int[3]; byte *fg_ptr; fixed(short *pWeightArray = filter().weight_array()) { short *weight_array = pWeightArray; weight_array = &pWeightArray[((filter().diameter() / 2 - 1) << (int)image_subpixel_scale_e.Shift)]; do { int x_hr; int y_hr; spanInterpolator.Coordinates(out x_hr, out y_hr); x_hr -= filter_dx_int(); y_hr -= filter_dy_int(); int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift; int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift; uint weight; fg[0] = fg[1] = fg[2] = (int)image_filter_scale_e.Scale / 2; x_hr &= (int)image_subpixel_scale_e.Mask; y_hr &= (int)image_subpixel_scale_e.Mask; fg_ptr = source().Span(x_lr, y_lr, 2); weight = (uint)((weight_array[x_hr + (int)image_subpixel_scale_e.Scale] * weight_array[y_hr + (int)image_subpixel_scale_e.Scale] + (int)image_filter_scale_e.Scale / 2) >> (int)image_filter_scale_e.Shift); fg[0] += (int)weight * *fg_ptr++; fg[1] += (int)weight * *fg_ptr++; fg[2] += (int)weight * *fg_ptr; fg_ptr = source().NextX(); weight = (uint)((weight_array[x_hr] * weight_array[y_hr + (int)image_subpixel_scale_e.Scale] + (int)image_filter_scale_e.Scale / 2) >> (int)image_filter_scale_e.Shift); fg[0] += (int)weight * *fg_ptr++; fg[1] += (int)weight * *fg_ptr++; fg[2] += (int)weight * *fg_ptr; fg_ptr = source().NextY(); weight = (uint)((weight_array[x_hr + (int)image_subpixel_scale_e.Scale] * weight_array[y_hr] + (int)image_filter_scale_e.Scale / 2) >> (int)image_filter_scale_e.Shift); fg[0] += (int)weight * *fg_ptr++; fg[1] += (int)weight * *fg_ptr++; fg[2] += (int)weight * *fg_ptr; fg_ptr = source().NextX(); weight = (uint)((weight_array[x_hr] * weight_array[y_hr] + (int)image_filter_scale_e.Scale / 2) >> (int)image_filter_scale_e.Shift); fg[0] += (int)weight * *fg_ptr++; fg[1] += (int)weight * *fg_ptr++; fg[2] += (int)weight * *fg_ptr; fg[0] >>= (int)image_filter_scale_e.Shift; fg[1] >>= (int)image_filter_scale_e.Shift; fg[2] >>= (int)image_filter_scale_e.Shift; if (fg[OrderR] > base_mask) { fg[OrderR] = base_mask; } if (fg[OrderG] > base_mask) { fg[OrderG] = base_mask; } if (fg[OrderB] > base_mask) { fg[OrderB] = base_mask; } span->R_Byte = (byte)fg[OrderR]; span->G_Byte = (byte)fg[OrderG]; span->B_Byte = (byte)fg[OrderB]; span->A_Byte = (uint)base_mask; ++span; spanInterpolator.Next(); } while (--len != 0); } }
//-------------------------------------------------------------------- public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len) { base.interpolator().Begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), len); int *fg = stackalloc int[3]; byte *fg_ptr; uint diameter = m_filter.diameter(); int start = m_filter.start(); short[] weight_array = m_filter.weight_array(); int x_count; int weight_y; ISpanInterpolator spanInterpolator = base.interpolator(); do { spanInterpolator.Coordinates(out x, out y); x -= base.filter_dx_int(); y -= base.filter_dy_int(); int x_hr = x; int y_hr = y; int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift; int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift; fg[0] = fg[1] = fg[2] = (int)image_filter_scale_e.Scale / 2; int x_fract = x_hr & (int)image_subpixel_scale_e.Mask; uint y_count = diameter; y_hr = (int)image_subpixel_scale_e.Mask - (y_hr & (int)image_subpixel_scale_e.Mask); fg_ptr = source().Span(x_lr + start, y_lr + start, diameter); for (; ;) { x_count = (int)diameter; weight_y = weight_array[y_hr]; x_hr = (int)image_subpixel_scale_e.Mask - x_fract; for (; ;) { int weight = (weight_y * weight_array[x_hr] + (int)image_filter_scale_e.Scale / 2) >> (int)image_filter_scale_e.Shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr; if (--x_count == 0) { break; } x_hr += (int)image_subpixel_scale_e.Scale; fg_ptr = source().NextX(); } if (--y_count == 0) { break; } y_hr += (int)image_subpixel_scale_e.Scale; fg_ptr = source().NextY(); } fg[0] >>= (int)image_filter_scale_e.Shift; fg[1] >>= (int)image_filter_scale_e.Shift; fg[2] >>= (int)image_filter_scale_e.Shift; if (fg[0] < 0) { fg[0] = 0; } if (fg[1] < 0) { fg[1] = 0; } if (fg[2] < 0) { fg[2] = 0; } if (fg[OrderR] > base_mask) { fg[OrderR] = (int)base_mask; } if (fg[OrderG] > base_mask) { fg[OrderG] = (int)base_mask; } if (fg[OrderB] > base_mask) { fg[OrderB] = (int)base_mask; } span->R_Byte = (Byte)fg[OrderR]; span->G_Byte = (Byte)fg[OrderG]; span->B_Byte = (Byte)fg[OrderB]; span->A_Byte = base_mask; ++span; spanInterpolator.Next(); } while (--len != 0); }
//-------------------------------------------------------------------- public override unsafe void Generate(RGBA_Bytes *span, int x, int y, uint len) { #if use_timers Generate_Span.Start(); #endif base.Interpolator.Begin(M.New <T>(x).Add(base.FilterDxDbl()), M.New <T>(y).Add(base.FilterDyDbl()), len); uint *fg = stackalloc uint[3]; uint src_alpha; uint back_r = m_back_color.R; uint back_g = m_back_color.G; uint back_b = m_back_color.B; uint back_a = m_back_color.A; byte *fg_ptr; RasterBuffer SourceRenderingBuffer = base.Source().PixelFormat.GetRenderingBuffer(); int maxx = (int)SourceRenderingBuffer.Width - 1; int maxy = (int)SourceRenderingBuffer.Height - 1; ISpanInterpolator <T> spanInterpolator = base.Interpolator; unchecked { do { int x_hr; int y_hr; spanInterpolator.Coordinates(out x_hr, out y_hr); x_hr -= base.FilterDxInt(); y_hr -= base.FilterDyInt(); int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift; int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift; uint weight; if (x_lr >= 0 && y_lr >= 0 && x_lr < maxx && y_lr < maxy) { fg[0] = fg[1] = fg[2] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2; x_hr &= (int)image_subpixel_scale_e.Mask; y_hr &= (int)image_subpixel_scale_e.Mask; fg_ptr = SourceRenderingBuffer.GetPixelPointer(y_lr) + x_lr * 3; weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * ((int)image_subpixel_scale_e.Scale - y_hr)); fg[0] += weight * fg_ptr[0]; fg[1] += weight * fg_ptr[1]; fg[2] += weight * fg_ptr[2]; weight = (uint)(x_hr * ((int)image_subpixel_scale_e.Scale - y_hr)); fg[0] += weight * fg_ptr[3]; fg[1] += weight * fg_ptr[4]; fg[2] += weight * fg_ptr[5]; ++y_lr; fg_ptr = SourceRenderingBuffer.GetPixelPointer(y_lr) + x_lr * 3; weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * y_hr); fg[0] += weight * fg_ptr[0]; fg[1] += weight * fg_ptr[1]; fg[2] += weight * fg_ptr[2]; weight = (uint)(x_hr * y_hr); fg[0] += weight * fg_ptr[3]; fg[1] += weight * fg_ptr[4]; fg[2] += weight * fg_ptr[5]; fg[0] >>= (int)image_subpixel_scale_e.Shift * 2; fg[1] >>= (int)image_subpixel_scale_e.Shift * 2; fg[2] >>= (int)image_subpixel_scale_e.Shift * 2; src_alpha = BaseMask; } else { if (x_lr < -1 || y_lr < -1 || x_lr > maxx || y_lr > maxy) { fg[OrderR] = back_r; fg[OrderG] = back_g; fg[OrderB] = back_b; src_alpha = back_a; } else { fg[0] = fg[1] = fg[2] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2; src_alpha = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2; x_hr &= (int)image_subpixel_scale_e.Mask; y_hr &= (int)image_subpixel_scale_e.Mask; weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * ((int)image_subpixel_scale_e.Scale - y_hr)); BlendInFilterPixel(fg, ref src_alpha, back_r, back_g, back_b, back_a, SourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight); x_lr++; weight = (uint)(x_hr * ((int)image_subpixel_scale_e.Scale - y_hr)); BlendInFilterPixel(fg, ref src_alpha, back_r, back_g, back_b, back_a, SourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight); x_lr--; y_lr++; weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * y_hr); BlendInFilterPixel(fg, ref src_alpha, back_r, back_g, back_b, back_a, SourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight); x_lr++; weight = (uint)(x_hr * y_hr); BlendInFilterPixel(fg, ref src_alpha, back_r, back_g, back_b, back_a, SourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight); fg[0] >>= (int)image_subpixel_scale_e.Shift * 2; fg[1] >>= (int)image_subpixel_scale_e.Shift * 2; fg[2] >>= (int)image_subpixel_scale_e.Shift * 2; src_alpha >>= (int)image_subpixel_scale_e.Shift * 2; } } //(*span).R = (byte)fg[0]; //(*span).G = (byte)fg[1]; //(*span).B = (byte)fg[2]; //(*span).A = (byte)src_alpha; (*span) = new RGBA_Bytes((byte)fg[0], (byte)fg[1], (byte)fg[2], (byte)src_alpha); ++span; spanInterpolator.Next(); } while (--len != 0); } #if use_timers Generate_Span.Stop(); #endif }
public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len) { #if use_timers Generate_Span.Start(); #endif base.Interpolator.Begin(M.New <T>(x).Add(base.FilterDxDbl()), M.New <T>(y).Add(base.FilterDyDbl()), len); uint *fg = stackalloc uint[4]; byte *fg_ptr; RasterBuffer pSourceRenderingBuffer = base.Source().PixelFormat.GetRenderingBuffer(); int maxx = (int)pSourceRenderingBuffer.Width - 1; int maxy = (int)pSourceRenderingBuffer.Height - 1; ISpanInterpolator <T> spanInterpolator = base.Interpolator; unchecked { do { int x_hr; int y_hr; spanInterpolator.Coordinates(out x_hr, out y_hr); x_hr -= base.FilterDxInt(); y_hr -= base.FilterDyInt(); int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift; int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift; uint weight; fg[0] = fg[1] = fg[2] = fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2; x_hr &= (int)image_subpixel_scale_e.Mask; y_hr &= (int)image_subpixel_scale_e.Mask; fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2); weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * ((int)image_subpixel_scale_e.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 = (uint)(x_hr * ((int)image_subpixel_scale_e.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 = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2); weight = (uint)(((int)image_subpixel_scale_e.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 = (uint)(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.Shift * 2; fg[1] >>= (int)image_subpixel_scale_e.Shift * 2; fg[2] >>= (int)image_subpixel_scale_e.Shift * 2; fg[3] >>= (int)image_subpixel_scale_e.Shift * 2; //(*span).R = (byte)fg[OrderR]; //(*span).G = (byte)fg[OrderG]; //(*span).B = (byte)fg[OrderB]; //(*span).A = (byte)fg[OrderA]; (*span) = new RGBA_Bytes((byte)fg[OrderR], (byte)fg[OrderG], (byte)fg[OrderB], (byte)fg[OrderA]); ++span; spanInterpolator.Next(); } while (--len != 0); } #if use_timers Generate_Span.Stop(); #endif }
public unsafe void Generate(out RGBA_Bytes destPixel, int x, int y) { base.Interpolator.Begin(M.New <T>(x).Add(base.FilterDxDbl()), M.New <T>(y).Add(base.FilterDyDbl()), 1); uint *fg = stackalloc uint[4]; byte *fg_ptr; RasterBuffer pSourceRenderingBuffer = base.Source().PixelFormat.GetRenderingBuffer(); int maxx = (int)pSourceRenderingBuffer.Width - 1; int maxy = (int)pSourceRenderingBuffer.Height - 1; ISpanInterpolator <T> spanInterpolator = base.Interpolator; unchecked { int x_hr; int y_hr; spanInterpolator.Coordinates(out x_hr, out y_hr); x_hr -= base.FilterDxInt(); y_hr -= base.FilterDyInt(); int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift; int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift; uint weight; fg[0] = fg[1] = fg[2] = fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2; x_hr &= (int)image_subpixel_scale_e.Mask; y_hr &= (int)image_subpixel_scale_e.Mask; fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2); weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * ((int)image_subpixel_scale_e.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 = (uint)(x_hr * ((int)image_subpixel_scale_e.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 = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2); weight = (uint)(((int)image_subpixel_scale_e.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 = (uint)(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.Shift * 2; fg[1] >>= (int)image_subpixel_scale_e.Shift * 2; fg[2] >>= (int)image_subpixel_scale_e.Shift * 2; fg[3] >>= (int)image_subpixel_scale_e.Shift * 2; destPixel = new RGBA_Bytes((byte)fg[OrderR], (byte)fg[OrderG], (byte)fg[OrderB], (byte)fg[OrderA]); //destPixel.R = (byte)fg[OrderR]; //destPixel.G = (byte)fg[OrderG]; //destPixel.B = (byte)fg[OrderB]; //destPixel.A = (byte)fg[OrderA]; } }
//---------------------------------------------------------------- public void Coordinates(out int x, out int y) { m_interpolator.Coordinates(out x, out y); }
//-------------------------------------------------------------------- public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len) { ISpanInterpolator <T> spanInterpolator = base.Interpolator; spanInterpolator.Begin(M.New <T>(x).Add(base.FilterDxDbl()), M.New <T>(y).Add(base.FilterDyDbl()), len); int *fg = stackalloc int[3]; byte *fg_ptr; fixed(short *pWeightArray = Filter.WeightArray()) { int diameter = (int)base.Filter.Diameter(); int filter_scale = diameter << (int)image_subpixel_scale_e.Shift; short *weight_array = pWeightArray; do { int rx; int ry; int rx_inv = (int)image_subpixel_scale_e.Scale; int ry_inv = (int)image_subpixel_scale_e.Scale; spanInterpolator.Coordinates(out x, out y); spanInterpolator.LocalScale(out rx, out ry); base.AdjustScale(ref rx, ref ry); rx_inv = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / rx; ry_inv = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / ry; int radius_x = (diameter * rx) >> 1; int radius_y = (diameter * ry) >> 1; int len_x_lr = (diameter * rx + (int)image_subpixel_scale_e.Mask) >> (int)(int)image_subpixel_scale_e.Shift; x += base.FilterDxInt() - radius_x; y += base.FilterDyInt() - radius_y; fg[0] = fg[1] = fg[2] = (int)image_filter_scale_e.Scale / 2; int y_lr = y >> (int)(int)image_subpixel_scale_e.Shift; int y_hr = (((int)image_subpixel_scale_e.Mask - (y & (int)image_subpixel_scale_e.Mask)) * ry_inv) >> (int)(int)image_subpixel_scale_e.Shift; int total_weight = 0; int x_lr = x >> (int)(int)image_subpixel_scale_e.Shift; int x_hr = (((int)image_subpixel_scale_e.Mask - (x & (int)image_subpixel_scale_e.Mask)) * rx_inv) >> (int)(int)image_subpixel_scale_e.Shift; int x_hr2 = x_hr; fg_ptr = base.Source().span(x_lr, y_lr, (uint)len_x_lr); for (; ;) { int weight_y = weight_array[y_hr]; x_hr = x_hr2; for (; ;) { int weight = (weight_y * weight_array[x_hr] + (int)image_filter_scale_e.Scale / 2) >> DownscaleShift; fg[0] += *fg_ptr++ *weight; fg[1] += *fg_ptr++ *weight; fg[2] += *fg_ptr++ *weight; total_weight += weight; x_hr += rx_inv; if (x_hr >= filter_scale) { break; } fg_ptr = base.Source().next_x(); } y_hr += ry_inv; if (y_hr >= filter_scale) { break; } fg_ptr = base.Source().next_y(); } fg[0] /= total_weight; fg[1] /= total_weight; fg[2] /= total_weight; if (fg[0] < 0) { fg[0] = 0; } if (fg[1] < 0) { fg[1] = 0; } if (fg[2] < 0) { fg[2] = 0; } if (fg[0] > fg[0]) { fg[0] = fg[0]; } if (fg[1] > fg[1]) { fg[1] = fg[1]; } if (fg[2] > fg[2]) { fg[2] = fg[2]; } //span->R_Byte = (byte)fg[OrderR]; //span->G_Byte = (byte)fg[OrderG]; //span->B_Byte = (byte)fg[OrderB]; //span->A_Byte = (byte)BaseMask; (*span) = new RGBA_Bytes((byte)fg[OrderR], (byte)fg[OrderG], (byte)fg[OrderB], (byte)BaseMask); ++span; Interpolator.Next(); } while (--len != 0); } }
//-------------------------------------------------------------------- public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len) { ISpanInterpolator <T> spanInterpolator = base.Interpolator; spanInterpolator.Begin(M.New <T>(x).Add(base.FilterDxDbl()), M.New <T>(y).Add(base.FilterDyDbl()), len); int *fg = stackalloc int[3]; byte *fg_ptr; fixed(short *pWeightArray = Filter.WeightArray()) { short *weight_array = pWeightArray; weight_array = &pWeightArray[((Filter.Diameter() / 2 - 1) << (int)image_subpixel_scale_e.Shift)]; do { int x_hr; int y_hr; spanInterpolator.Coordinates(out x_hr, out y_hr); x_hr -= FilterDxInt(); y_hr -= FilterDyInt(); int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift; int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift; uint weight; fg[0] = fg[1] = fg[2] = (int)image_filter_scale_e.Scale / 2; x_hr &= (int)image_subpixel_scale_e.Mask; y_hr &= (int)image_subpixel_scale_e.Mask; fg_ptr = Source().span(x_lr, y_lr, 2); weight = (uint)((weight_array[x_hr + (int)image_subpixel_scale_e.Scale] * weight_array[y_hr + (int)image_subpixel_scale_e.Scale] + (int)image_filter_scale_e.Scale / 2) >> (int)image_filter_scale_e.Shift); fg[0] += (int)weight * *fg_ptr++; fg[1] += (int)weight * *fg_ptr++; fg[2] += (int)weight * *fg_ptr; fg_ptr = Source().next_x(); weight = (uint)((weight_array[x_hr] * weight_array[y_hr + (int)image_subpixel_scale_e.Scale] + (int)image_filter_scale_e.Scale / 2) >> (int)image_filter_scale_e.Shift); fg[0] += (int)weight * *fg_ptr++; fg[1] += (int)weight * *fg_ptr++; fg[2] += (int)weight * *fg_ptr; fg_ptr = Source().next_y(); weight = (uint)((weight_array[x_hr + (int)image_subpixel_scale_e.Scale] * weight_array[y_hr] + (int)image_filter_scale_e.Scale / 2) >> (int)image_filter_scale_e.Shift); fg[0] += (int)weight * *fg_ptr++; fg[1] += (int)weight * *fg_ptr++; fg[2] += (int)weight * *fg_ptr; fg_ptr = Source().next_x(); weight = (uint)((weight_array[x_hr] * weight_array[y_hr] + (int)image_filter_scale_e.Scale / 2) >> (int)image_filter_scale_e.Shift); fg[0] += (int)weight * *fg_ptr++; fg[1] += (int)weight * *fg_ptr++; fg[2] += (int)weight * *fg_ptr; fg[0] >>= (int)image_filter_scale_e.Shift; fg[1] >>= (int)image_filter_scale_e.Shift; fg[2] >>= (int)image_filter_scale_e.Shift; if (fg[OrderR] > BaseMask) { fg[OrderR] = BaseMask; } if (fg[OrderG] > BaseMask) { fg[OrderG] = BaseMask; } if (fg[OrderB] > BaseMask) { fg[OrderB] = BaseMask; } //span->R_Byte = (byte)fg[OrderR]; //span->G_Byte = (byte)fg[OrderG]; //span->B_Byte = (byte)fg[OrderB]; //span->A_Byte = (uint)BaseMask; (*span) = new RGBA_Bytes((byte)fg[OrderR], (byte)fg[OrderG], (byte)fg[OrderB], (uint)BaseMask); ++span; spanInterpolator.Next(); } while (--len != 0); } }
//-------------------------------------------------------------------- public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len) { base.Interpolator.Begin(M.New <T>(x).Add(base.FilterDxDbl()), M.New <T>(y).Add(base.FilterDyDbl()), len); int *fg = stackalloc int[3]; byte *fg_ptr; uint diameter = m_filter.Diameter(); int start = m_filter.Start(); short[] weight_array = m_filter.WeightArray(); int x_count; int weight_y; ISpanInterpolator <T> spanInterpolator = base.Interpolator; do { spanInterpolator.Coordinates(out x, out y); x -= base.FilterDxInt(); y -= base.FilterDyInt(); int x_hr = x; int y_hr = y; int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift; int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift; fg[0] = fg[1] = fg[2] = (int)image_filter_scale_e.Scale / 2; int x_fract = x_hr & (int)image_subpixel_scale_e.Mask; uint y_count = diameter; y_hr = (int)image_subpixel_scale_e.Mask - (y_hr & (int)image_subpixel_scale_e.Mask); fg_ptr = Source().span(x_lr + start, y_lr + start, diameter); for (; ;) { x_count = (int)diameter; weight_y = weight_array[y_hr]; x_hr = (int)image_subpixel_scale_e.Mask - x_fract; for (; ;) { int weight = (weight_y * weight_array[x_hr] + (int)image_filter_scale_e.Scale / 2) >> (int)image_filter_scale_e.Shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr; if (--x_count == 0) { break; } x_hr += (int)image_subpixel_scale_e.Scale; fg_ptr = Source().next_x(); } if (--y_count == 0) { break; } y_hr += (int)image_subpixel_scale_e.Scale; fg_ptr = Source().next_y(); } fg[0] >>= (int)image_filter_scale_e.Shift; fg[1] >>= (int)image_filter_scale_e.Shift; fg[2] >>= (int)image_filter_scale_e.Shift; if (fg[0] < 0) { fg[0] = 0; } if (fg[1] < 0) { fg[1] = 0; } if (fg[2] < 0) { fg[2] = 0; } if (fg[OrderR] > BaseMask) { fg[OrderR] = (int)BaseMask; } if (fg[OrderG] > BaseMask) { fg[OrderG] = (int)BaseMask; } if (fg[OrderB] > BaseMask) { fg[OrderB] = (int)BaseMask; } //span->R_Byte = (Byte)fg[OrderR]; //span->G_Byte = (Byte)fg[OrderG]; //span->B_Byte = (Byte)fg[OrderB]; //span->A_Byte = BaseMask; (*span) = new RGBA_Bytes((Byte)fg[OrderR], (Byte)fg[OrderG], (Byte)fg[OrderB], BaseMask); ++span; spanInterpolator.Next(); } while (--len != 0); }
//-------------------------------------------------------------------- public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len) { ISpanInterpolator spanInterpolator = base.interpolator(); spanInterpolator.Begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), len); int *fg = stackalloc int[4]; byte *fg_ptr; fixed(short *pWeightArray = filter().weight_array()) { int diameter = (int)base.filter().diameter(); int filter_scale = diameter << (int)image_subpixel_scale_e.Shift; short *weight_array = pWeightArray; do { int rx; int ry; int rx_inv = (int)image_subpixel_scale_e.Scale; int ry_inv = (int)image_subpixel_scale_e.Scale; spanInterpolator.Coordinates(out x, out y); spanInterpolator.LocalScale(out rx, out ry); base.AdjustScale(ref rx, ref ry); rx_inv = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / rx; ry_inv = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / ry; int radius_x = (diameter * rx) >> 1; int radius_y = (diameter * ry) >> 1; int len_x_lr = (diameter * rx + (int)image_subpixel_scale_e.Mask) >> (int)(int)image_subpixel_scale_e.Shift; x += base.filter_dx_int() - radius_x; y += base.filter_dy_int() - radius_y; fg[0] = fg[1] = fg[2] = fg[3] = (int)image_filter_scale_e.Scale / 2; int y_lr = y >> (int)(int)image_subpixel_scale_e.Shift; int y_hr = (((int)image_subpixel_scale_e.Mask - (y & (int)image_subpixel_scale_e.Mask)) * ry_inv) >> (int)(int)image_subpixel_scale_e.Shift; int total_weight = 0; int x_lr = x >> (int)(int)image_subpixel_scale_e.Shift; int x_hr = (((int)image_subpixel_scale_e.Mask - (x & (int)image_subpixel_scale_e.Mask)) * rx_inv) >> (int)(int)image_subpixel_scale_e.Shift; int x_hr2 = x_hr; fg_ptr = base.source().Span(x_lr, y_lr, (uint)len_x_lr); for (; ;) { int weight_y = weight_array[y_hr]; x_hr = x_hr2; for (; ;) { int weight = (weight_y * weight_array[x_hr] + (int)image_filter_scale_e.Scale / 2) >> downscale_shift; fg[0] += *fg_ptr++ *weight; fg[1] += *fg_ptr++ *weight; fg[2] += *fg_ptr++ *weight; fg[3] += *fg_ptr++ *weight; total_weight += weight; x_hr += rx_inv; if (x_hr >= filter_scale) { break; } fg_ptr = base.source().NextX(); } y_hr += ry_inv; if (y_hr >= filter_scale) { break; } fg_ptr = base.source().NextY(); } fg[0] /= total_weight; fg[1] /= total_weight; fg[2] /= total_weight; fg[3] /= total_weight; if (fg[0] < 0) { fg[0] = 0; } if (fg[1] < 0) { fg[1] = 0; } if (fg[2] < 0) { fg[2] = 0; } if (fg[3] < 0) { fg[3] = 0; } if (fg[0] > fg[0]) { fg[0] = fg[0]; } if (fg[1] > fg[1]) { fg[1] = fg[1]; } if (fg[2] > fg[2]) { fg[2] = fg[2]; } if (fg[3] > base_mask) { fg[3] = base_mask; } span->R_Byte = (byte)fg[OrderR]; span->G_Byte = (byte)fg[OrderG]; span->B_Byte = (byte)fg[OrderB]; span->A_Byte = (byte)fg[OrderA]; ++span; interpolator().Next(); } while (--len != 0); } }
public unsafe void Generate(out RGBA_Bytes destPixel, int x, int y) { base.interpolator().Begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), 1); uint *fg = stackalloc uint[4]; byte *fg_ptr; RasterBuffer pSourceRenderingBuffer = base.source().PixelFormat.RenderingBuffer; int maxx = (int)pSourceRenderingBuffer.Width() - 1; int maxy = (int)pSourceRenderingBuffer.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.Shift; int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift; uint weight; fg[0] = fg[1] = fg[2] = fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2; x_hr &= (int)image_subpixel_scale_e.Mask; y_hr &= (int)image_subpixel_scale_e.Mask; fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2); weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * ((int)image_subpixel_scale_e.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 = (uint)(x_hr * ((int)image_subpixel_scale_e.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 = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2); weight = (uint)(((int)image_subpixel_scale_e.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 = (uint)(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.Shift * 2; fg[1] >>= (int)image_subpixel_scale_e.Shift * 2; fg[2] >>= (int)image_subpixel_scale_e.Shift * 2; fg[3] >>= (int)image_subpixel_scale_e.Shift * 2; destPixel.m_R = (byte)fg[OrderR]; destPixel.m_G = (byte)fg[OrderG]; destPixel.m_B = (byte)fg[OrderB]; destPixel.m_A = (byte)fg[OrderA]; } }
//-------------------------------------------------------------------- public override unsafe void Generate(RGBA_Bytes *span, int x, int y, uint len) { #if use_timers Generate_Span.Start(); #endif base.Interpolator.Begin(x + base.FilterDxDbl(), y + base.FilterDyDbl(), len); uint *fg = stackalloc uint[3]; uint src_alpha; RasterBuffer SourceRenderingBuffer = base.Source().PixelFormat.GetRenderingBuffer(); ISpanInterpolator spanInterpolator = base.Interpolator; unchecked { do { int x_hr; int y_hr; spanInterpolator.Coordinates(out x_hr, out y_hr); x_hr -= base.FilterDxInt(); y_hr -= base.FilterDyInt(); int x_lrX3 = (x_hr >> (int)image_subpixel_scale_e.Shift) * 3; int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift; uint weight; fg[0] = fg[1] = fg[2] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2; x_hr &= (int)image_subpixel_scale_e.Mask; y_hr &= (int)image_subpixel_scale_e.Mask; byte *fg_ptr = SourceRenderingBuffer.GetPixelPointer(y_lr) + x_lrX3; weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * ((int)image_subpixel_scale_e.Scale - y_hr)); fg[0] += weight * fg_ptr[0]; fg[1] += weight * fg_ptr[1]; fg[2] += weight * fg_ptr[2]; weight = (uint)(x_hr * ((int)image_subpixel_scale_e.Scale - y_hr)); fg[0] += weight * fg_ptr[3]; fg[1] += weight * fg_ptr[4]; fg[2] += weight * fg_ptr[5]; ++y_lr; fg_ptr = SourceRenderingBuffer.GetPixelPointer(y_lr) + x_lrX3; weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * y_hr); fg[0] += weight * fg_ptr[0]; fg[1] += weight * fg_ptr[1]; fg[2] += weight * fg_ptr[2]; weight = (uint)(x_hr * y_hr); fg[0] += weight * fg_ptr[3]; fg[1] += weight * fg_ptr[4]; fg[2] += weight * fg_ptr[5]; fg[0] >>= (int)image_subpixel_scale_e.Shift * 2; fg[1] >>= (int)image_subpixel_scale_e.Shift * 2; fg[2] >>= (int)image_subpixel_scale_e.Shift * 2; src_alpha = BaseMask; (*span).m_R = (byte)fg[OrderR]; (*span).m_G = (byte)fg[OrderG]; (*span).m_B = (byte)fg[OrderB]; (*span).m_A = (byte)src_alpha; ++span; spanInterpolator.Next(); } while(--len != 0); } #if use_timers Generate_Span.Stop(); #endif }