//-------------------------------------------------------------------- public override unsafe void CopyHorizontalColorSpan(int x, int y, uint len, RGBA_Bytes *colors) { if (y > MaxY) { return; } if (y < MinY) { return; } if (x < MinX) { int d = MinX - x; len -= (uint)d; if (len <= 0) { return; } colors += d; x = MinX; } if (x + len > MaxX) { len = (uint)(MaxX - x + 1); if (len <= 0) { return; } } base.CopyHorizontalColorSpan(x, y, len, colors); }
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 override unsafe void CopyColorVSpan(int x, int y, uint len, RGBA_Bytes *colors) { if (x > XMax()) { return; } if (x < XMin()) { return; } if (y < YMin()) { int d = YMin() - y; len -= (uint)d; if (len <= 0) { return; } colors += d; y = YMin(); } if (y + len > YMax()) { len = (uint)(YMax() - y + 1); if (len <= 0) { return; } } base.CopyColorVSpan(x, y, len, colors); }
//-------------------------------------------------------------------- public unsafe void pixel(RGBA_Bytes *p, int x, int y) { m_filter.pixel_high_res(m_buf, p, x % m_width_hr + m_dilation_hr, y + m_offset_y_hr); }
//-------------------------------------------------------------------- public override unsafe void CopyColorHSpan(int x, int y, uint len, RGBA_Bytes *colors) { if (y > YMax()) { return; } if (y < YMin()) { return; } if (x < XMin()) { int d = XMin() - x; len -= (uint)d; if (len <= 0) { return; } colors += d; x = XMin(); } if (x + len > XMax()) { len = (uint)(XMax() - x + 1); if (len <= 0) { return; } } base.CopyColorHSpan(x, y, len, colors); }
//-------------------------------------------------------------------- public unsafe void BlendHorizontalColorSpan(int x, int y, uint len, RGBA_Bytes *colors, byte *covers) { throw new System.NotImplementedException(); //BlendHorizontalColorSpan(x, y, len, Colors, covers, CoverFull); }
public unsafe void BlendVerticalColorSpan(int x, int y, uint len, RGBA_Bytes *colors, byte *covers, byte cover) { byte *p = _rasterBuffer.GetPixelPointer(y) + x + x + x; int scanWidth = _rasterBuffer.StrideInBytes(); if (covers != null) { do { CopyOrBlendBGRWrapper.CopyOrBlendPixel(_blender, p, colors->m_R, colors->m_G, colors->m_B, colors->m_A, *covers++); p = &p[scanWidth]; ++colors; }while (--len != 0); } else { if (cover == 255) { do { CopyOrBlendBGRWrapper.CopyOrBlendPixel(_blender, p, colors->R_Byte, colors->G_Byte, colors->B_Byte, colors->A_Byte); p = &p[scanWidth]; ++colors; }while (--len != 0); } else { do { CopyOrBlendBGRWrapper.CopyOrBlendPixel(_blender, p, colors->R_Byte, colors->G_Byte, colors->B_Byte, colors->A_Byte, cover); p = &p[scanWidth]; ++colors; }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 override unsafe void CopyVerticalColorSpan(int x, int y, uint len, RGBA_Bytes *colors) { if (x > MaxX) { return; } if (x < MinX) { return; } if (y < MinY) { int d = MinY - y; len -= (uint)d; if (len <= 0) { return; } colors += d; y = MinY; } if (y + len > MaxY) { len = (uint)(MaxY - y + 1); if (len <= 0) { return; } } base.CopyVerticalColorSpan(x, y, len, colors); }
///<summary> ///</summary> ///<param name="x"></param> ///<param name="y"></param> ///<param name="len"></param> ///<param name="colors"></param> public override unsafe void CopyVerticalColorSpan(int x, int y, uint len, RGBA_Bytes *colors) { ReallocateSpan((int)len); fixed(byte *pBuffer = _span.Array) { _alphaMask.FillVerticalSpan(x, y, pBuffer, (int)len); PixelFormat.BlendVerticalColorSpan(x, y, len, colors, pBuffer, CoverFull); } }
public unsafe void PixelHighRes(RasterBuffer buf, RGBA_Bytes *p, int x, int y) { int r, g, b, a; r = g = b = a = LineAABasics.LineSubPixelScale * LineAABasics.LineSubPixelScale / 2; int weight; int x_lr = x >> LineAABasics.LineSubPixelShift; int y_lr = y >> LineAABasics.LineSubPixelShift; x &= LineAABasics.LineSubPixelMask; y &= LineAABasics.LineSubPixelMask; RGBA_Bytes *ptr = (RGBA_Bytes *)buf.GetPixelPointer(x_lr, y_lr); weight = (LineAABasics.LineSubPixelScale - x) * (LineAABasics.LineSubPixelScale - y); r += weight * ptr->R; g += weight * ptr->G; b += weight * ptr->B; a += weight * ptr->A; ++ptr; weight = x * (LineAABasics.LineSubPixelScale - y); r += weight * ptr->R; g += weight * ptr->G; b += weight * ptr->B; a += weight * ptr->A; ptr = (RGBA_Bytes *)buf.GetPixelPointer(x_lr, y_lr + 1); weight = (LineAABasics.LineSubPixelScale - x) * y; r += weight * ptr->R; g += weight * ptr->G; b += weight * ptr->B; a += weight * ptr->A; ++ptr; weight = x * y; r += weight * ptr->R; g += weight * ptr->G; b += weight * ptr->B; a += weight * ptr->A; //p->R = (byte)(r >> LineAABasics.LineSubPixelShift * 2); //p->G = (byte)(g >> LineAABasics.LineSubPixelShift * 2); //p->B = (byte)(b >> LineAABasics.LineSubPixelShift * 2); //p->A = (byte)(a >> LineAABasics.LineSubPixelShift * 2); (*p) = new RGBA_Bytes( (byte)(r >> LineAABasics.LineSubPixelShift * 2), (byte)(g >> LineAABasics.LineSubPixelShift * 2), (byte)(b >> LineAABasics.LineSubPixelShift * 2), (byte)(a >> LineAABasics.LineSubPixelShift * 2)); }
unsafe public void CopyHorizontalColorSpan(int x, int y, uint len, RGBA_Bytes *colors) { byte *p = m_rbuf.GetPixelPointer(y) + x * m_Step + m_Offset; do { *p = colors[0].m_R; p += m_Step; ++colors; }while (--len != 0); }
//-------------------------------------------------------------------- public override unsafe void CopyColorVSpan(int x, int y, uint len, RGBA_Bytes *colors) { ReAllocSpan((int)len); unsafe { fixed(byte *pBuffer = m_span.Array) { m_mask.FillVSpan(x, y, pBuffer, (int)len); m_pixf.BlendColorVSpan(x, y, len, colors, pBuffer, CoverFull); } } }
//-------------------------------------------------------------------- unsafe public void CopyVerticalColorSpan(int x, int y, uint len, RGBA_Bytes *colors) { byte *p = m_rbuf.GetPixelPointer(y) + x * m_Step + m_Offset; int ScanWidth = m_rbuf.StrideInBytes(); do { *p = colors[0].m_R; p = &p[ScanWidth]; ++colors; }while (--len != 0); }
//-------------------------------------------------------------------- unsafe public void CopyHorizontalColorSpan(int x, int y, uint len, RGBA_Bytes *colors) { byte *p = _rasterBuffer.GetPixelPointer(y) + x + x + x; do { p[_orderR] = colors[0].m_R; p[_orderG] = colors[0].m_G; p[_orderB] = colors[0].m_B; ++colors; p += 3; }while (--len != 0); }
public unsafe void PixelHighResolution(RasterBuffer buf, RGBA_Bytes *p, int x, int y) { int r, g, b, a; r = g = b = a = LineAABasics.line_subpixel_scale * LineAABasics.line_subpixel_scale / 2; int weight; int x_lr = x >> LineAABasics.line_subpixel_shift; int y_lr = y >> LineAABasics.line_subpixel_shift; x &= LineAABasics.line_subpixel_mask; y &= LineAABasics.line_subpixel_mask; RGBA_Bytes *ptr = (RGBA_Bytes *)buf.GetPixelPointer(x_lr, y_lr); weight = (LineAABasics.line_subpixel_scale - x) * (LineAABasics.line_subpixel_scale - y); r += weight * ptr->m_R; g += weight * ptr->m_G; b += weight * ptr->m_B; a += weight * ptr->m_A; ++ptr; weight = x * (LineAABasics.line_subpixel_scale - y); r += weight * ptr->m_R; g += weight * ptr->m_G; b += weight * ptr->m_B; a += weight * ptr->m_A; ptr = (RGBA_Bytes *)buf.GetPixelPointer(x_lr, y_lr + 1); weight = (LineAABasics.line_subpixel_scale - x) * y; r += weight * ptr->m_R; g += weight * ptr->m_G; b += weight * ptr->m_B; a += weight * ptr->m_A; ++ptr; weight = x * y; r += weight * ptr->m_R; g += weight * ptr->m_G; b += weight * ptr->m_B; a += weight * ptr->m_A; p->m_R = (byte)(r >> LineAABasics.line_subpixel_shift * 2); p->m_G = (byte)(g >> LineAABasics.line_subpixel_shift * 2); p->m_B = (byte)(b >> LineAABasics.line_subpixel_shift * 2); p->m_A = (byte)(a >> LineAABasics.line_subpixel_shift * 2); }
//-------------------------------------------------------------------- public unsafe void CopyVerticalColorSpan(int x, int y, uint len, RGBA_Bytes *colors) { int scanWidth = _rasterBuffer.StrideInBytes(); byte *p = _rasterBuffer.GetPixelPointer(y) + x + x + x; do { p[_orderR] = colors[0].m_R; p[_orderG] = colors[0].m_G; p[_orderB] = colors[0].m_B; p = &p[scanWidth]; ++colors; }while (--len != 0); }
//-------------------------------------------------------------------- unsafe public void BlendHorizontalColorSpan(int x, int y, uint len, RGBA_Bytes *colors, byte *covers, byte cover) { byte *p = _rasterBuffer.GetPixelPointer(y) + x + x + x; if (covers != null) { do { CopyOrBlendBGRWrapper.CopyOrBlendPixel(_blender, p, colors->m_R, colors->m_G, colors->m_B, colors->m_A, *covers++); p += 3; ++colors; }while (--len != 0); } else { if (cover == 255) { do { CopyOrBlendBGRWrapper.CopyOrBlendPixel(_blender, p, colors->R_Byte, colors->G_Byte, colors->B_Byte, colors->A_Byte); p += 3; ++colors; }while (--len != 0); } else { do { CopyOrBlendBGRWrapper.CopyOrBlendPixel(_blender, p, colors->R_Byte, colors->G_Byte, colors->B_Byte, colors->A_Byte, cover); p += 3; ++colors; }while (--len != 0); } } }
///<summary> ///</summary> ///<param name="x"></param> ///<param name="y"></param> ///<param name="len"></param> ///<param name="colors"></param> ///<param name="covers"></param> ///<param name="cover"></param> public override unsafe void BlendVerticalColorSpan(int x, int y, uint len, RGBA_Bytes *colors, byte *covers, byte cover) { fixed(byte *pBuffer = _span.Array) { if (covers != null) { InitSpan((int)len, covers); _alphaMask.CombineVerticalSpan(x, y, pBuffer, (int)len); } else { ReallocateSpan((int)len); _alphaMask.FillVerticalSpan(x, y, pBuffer, (int)len); } PixelFormat.BlendVerticalColorSpan(x, y, len, colors, pBuffer, cover); } }
//-------------------------------------------------------------------- public override unsafe void BlendColorVSpan(int x, int y, uint len, RGBA_Bytes *colors, byte *covers, byte cover) { unsafe { fixed(byte *pBuffer = m_span.Array) { if (covers != null) { InitSpan((int)len, covers); m_mask.CombineVSpan(x, y, pBuffer, (int)len); } else { ReAllocSpan((int)len); m_mask.FillVSpan(x, y, pBuffer, (int)len); } m_pixf.BlendColorVSpan(x, y, len, colors, pBuffer, cover); } } }
public unsafe void BlendColorVSpan(int x, int y, uint len, RGBA_Bytes *colors, byte *covers, byte cover) { int ScanWidth = m_rbuf.StrideInBytes; byte *p = m_rbuf.GetPixelPointer(y) + x * m_Step + m_Offset; if (covers != null) { do { CopyOrBlendPix(p, *colors++, *covers++); p = &p[ScanWidth]; }while (--len != 0); } else { if (cover == 255) { do { if (colors[0].A == (byte)BaseMask) { *p = colors[0].A; } else { CopyOrBlendPix(p, *colors); } p = &p[ScanWidth]; ++colors; }while (--len != 0); } else { do { CopyOrBlendPix(p, *colors++, cover); p = &p[ScanWidth]; }while (--len != 0); } } }
public unsafe void BlendVerticalColorSpan(int x, int y, uint len, RGBA_Bytes *colors, byte *covers, byte cover) { int ScanWidth = m_rbuf.StrideInBytes(); byte *p = m_rbuf.GetPixelPointer(y) + x * m_Step + m_Offset; if (covers != null) { do { copy_or_blend_pix(p, *colors++, *covers++); p = &p[ScanWidth]; }while (--len != 0); } else { if (cover == 255) { do { if (colors[0].m_A == (byte)base_mask) { *p = colors[0].m_A; } else { copy_or_blend_pix(p, *colors); } p = &p[ScanWidth]; ++colors; }while (--len != 0); } else { do { copy_or_blend_pix(p, *colors++, cover); p = &p[ScanWidth]; }while (--len != 0); } } }
//-------------------------------------------------------------------- unsafe public void BlendColorHSpan(int x, int y, uint len, RGBA_Bytes *colors, byte *covers, byte cover) { byte *p = m_rbuf.GetPixelPointer(y) + x * m_Step + m_Offset; if (covers != null) { do { CopyOrBlendPix(p, *colors++, *covers++); p += m_Step; }while (--len != 0); } else { if (cover == 255) { do { if (colors[0].A == (byte)BaseMask) { *p = colors[0].A; } else { CopyOrBlendPix(p, *colors); } p += m_Step; ++colors; }while (--len != 0); } else { do { CopyOrBlendPix(p, *colors++, cover); p += m_Step; }while (--len != 0); } } }
//-------------------------------------------------------------------- unsafe public void BlendHorizontalColorSpan(int x, int y, uint len, RGBA_Bytes *colors, byte *covers, byte cover) { byte *p = m_rbuf.GetPixelPointer(y) + x * m_Step + m_Offset; if (covers != null) { do { copy_or_blend_pix(p, *colors++, *covers++); p += m_Step; }while (--len != 0); } else { if (cover == 255) { do { if (colors[0].m_A == (byte)base_mask) { *p = colors[0].m_A; } else { copy_or_blend_pix(p, *colors); } p += m_Step; ++colors; }while (--len != 0); } else { do { copy_or_blend_pix(p, *colors++, cover); p += m_Step; }while (--len != 0); } } }
public override unsafe void BlendColorHSpan(int x, int y, uint in_len, RGBA_Bytes *colors, byte *covers, byte cover) { int len = (int)in_len; if (y > YMax()) { return; } if (y < YMin()) { return; } if (x < XMin()) { int d = XMin() - x; len -= d; if (len <= 0) { return; } if (covers != null) { covers += d; } colors += d; x = XMin(); } if (x + len - 1 > XMax()) { len = XMax() - x + 1; if (len <= 0) { return; } } base.BlendColorHSpan(x, y, (uint)len, colors, covers, cover); }
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 override unsafe void BlendColorVSpan(int x, int y, uint len, RGBA_Bytes *colors, byte *covers, byte cover) { if (x > XMax()) { return; } if (x < XMin()) { return; } if (y < YMin()) { int d = YMin() - y; len -= (uint)d; if (len <= 0) { return; } if (covers != null) { covers += d; } colors += d; y = YMin(); } if (y + len > YMax()) { len = (uint)(YMax() - y + 1); if (len <= 0) { return; } } base.BlendColorVSpan(x, y, len, colors, covers, cover); }
//-------------------------------------------------------------------- public override unsafe void BlendVerticalColorSpan(int x, int y, uint len, RGBA_Bytes *colors, byte *covers, byte cover) { if (x > MaxX) { return; } if (x < MinX) { return; } if (y < MinY) { int d = MinY - y; len -= (uint)d; if (len <= 0) { return; } if (covers != null) { covers += d; } colors += d; y = MinY; } if (y + len > MaxY) { len = (uint)(MaxY - y + 1); if (len <= 0) { return; } } base.BlendVerticalColorSpan(x, y, len, colors, covers, cover); }
//--------------------------------------------------------------------- public bool step_ver() { ++m_li; m_y += m_lp.inc; m_x = (m_lp.x1 + m_li.y()) >> line_subpixel_shift; if (m_lp.inc > 0) { m_di.inc_y(m_x - m_old_x); } else { m_di.dec_y(m_x - m_old_x); } m_old_x = m_x; int s1 = m_di.dist() / m_lp.len; int s2 = -s1; if (m_lp.inc > 0) { s1 = -s1; } int dist_start; int dist_pict; int dist_end; int dist; int dx; dist_start = m_di.dist_start(); dist_pict = m_di.dist_pict() + m_start; dist_end = m_di.dist_end(); RGBA_Bytes *p0 = m_colors + max_half_width + 2; RGBA_Bytes *p1 = p0; int npix = 0; p1->clear(); if (dist_end > 0) { if (dist_start <= 0) { m_ren.pixel(p1, dist_pict, s2); } ++npix; } ++p1; dx = 1; while ((dist = m_dist_pos[dx]) - s1 <= m_width) { dist_start += m_di.dy_start(); dist_pict += m_di.dy_pict(); dist_end += m_di.dy_end(); p1->clear(); if (dist_end > 0 && dist_start <= 0) { if (m_lp.inc > 0) { dist = -dist; } m_ren.pixel(p1, dist_pict, s2 + dist); ++npix; } ++p1; ++dx; } dx = 1; dist_start = m_di.dist_start(); dist_pict = m_di.dist_pict() + m_start; dist_end = m_di.dist_end(); while ((dist = m_dist_pos[dx]) + s1 <= m_width) { dist_start -= m_di.dy_start(); dist_pict -= m_di.dy_pict(); dist_end -= m_di.dy_end(); --p0; p0->clear(); if (dist_end > 0 && dist_start <= 0) { if (m_lp.inc > 0) { dist = -dist; } m_ren.pixel(p0, dist_pict, s2 - dist); ++npix; } ++dx; } m_ren.blend_color_hspan(m_x - dx + 1, m_y, (uint)(p1 - p0), p0); return(npix && ++m_step < m_count); }
//--------------------------------------------------------------------- public bool step_hor() { ++m_li; m_x += m_lp.inc; m_y = (m_lp.y1 + m_li.y()) >> line_subpixel_shift; if (m_lp.inc > 0) { m_di.inc_x(m_y - m_old_y); } else { m_di.dec_x(m_y - m_old_y); } m_old_y = m_y; int s1 = m_di.dist() / m_lp.len; int s2 = -s1; if (m_lp.inc < 0) { s1 = -s1; } int dist_start; int dist_pict; int dist_end; int dy; int dist; dist_start = m_di.dist_start(); dist_pict = m_di.dist_pict() + m_start; dist_end = m_di.dist_end(); RGBA_Bytes *p0 = m_colors + max_half_width + 2; RGBA_Bytes *p1 = p0; int npix = 0; p1->clear(); if (dist_end > 0) { if (dist_start <= 0) { m_ren.pixel(p1, dist_pict, s2); } ++npix; } ++p1; dy = 1; while ((dist = m_dist_pos[dy]) - s1 <= m_width) { dist_start -= m_di.dx_start(); dist_pict -= m_di.dx_pict(); dist_end -= m_di.dx_end(); p1->clear(); if (dist_end > 0 && dist_start <= 0) { if (m_lp.inc > 0) { dist = -dist; } m_ren.pixel(p1, dist_pict, s2 - dist); ++npix; } ++p1; ++dy; } dy = 1; dist_start = m_di.dist_start(); dist_pict = m_di.dist_pict() + m_start; dist_end = m_di.dist_end(); while ((dist = m_dist_pos[dy]) + s1 <= m_width) { dist_start += m_di.dx_start(); dist_pict += m_di.dx_pict(); dist_end += m_di.dx_end(); --p0; p0->clear(); if (dist_end > 0 && dist_start <= 0) { if (m_lp.inc > 0) { dist = -dist; } m_ren.pixel(p0, dist_pict, s2 + dist); ++npix; } ++dy; } m_ren.blend_color_vspan(m_x, m_y - dy + 1, (uint)(p1 - p0), p0); return(npix && ++m_step < m_count); }