//--------------------------------------------------------------------
 public unsafe override void Generate(RGBA_Bytes* span, int x, int y, uint len)
 {
     RasterBuffer SourceRenderingBuffer = base.Source().PixelFormat.GetRenderingBuffer();
     ISpanInterpolator spanInterpolator = base.Interpolator;
     spanInterpolator.Begin(x + base.FilterDxDbl(), y + 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 = SourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr * 3);
         //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 = 255;
         ++span;
         spanInterpolator.Next();
     } while(--len != 0);
 }
Example #2
0
 public abstract void ToPix(ref RGBA_Bytes c);
 //-------------------------------------------------------------------------
 public unsafe void blend_color_vspan(int x, int y, uint len, RGBA_Bytes* colors)
 {
     m_ren.blend_color_vspan(x, y, len, colors, null, 0);
 }
Example #4
0
        public override void Render(IVertexSource vertexSource, int pathIndexToRender, RGBA_Bytes colorBytes)
        {
#if use_timers
            OpenGLRenderTimer.Start();
#endif
            PushOrthoProjection();

            vertexSource.rewind(pathIndexToRender);

            RGBA_Doubles color = colorBytes.GetAsRGBA_Doubles();

            Gl.glColor4d(color.m_r, color.m_g, color.m_b, color.m_a);

            Affine transform = GetTransform();
            if (!transform.is_identity())
            {
                vertexSource = new conv_transform(vertexSource, transform);
            }

            if (m_ForceTexturedEdgeAntiAliasing)
            {
                DrawAAShape(vertexSource);
            }
            else
            {
                SendShapeToTeselator(m_RenderNowTesselator, vertexSource);
            }

            PopOrthoProjection();
#if use_timers
            OpenGLRenderTimer.Stop();
#endif
        }
 //--------------------------------------------------------------------
 public RGBA_Bytes Gradient(RGBA_Bytes c, double k)
 {
     RGBA_Bytes ret = new RGBA_Bytes();
     uint ik = Basics.RoundUint(k * BaseScale);
     ret.R_Byte = (byte)((uint)(R_Byte) + ((((uint)(c.R_Byte) - R_Byte) * ik) >> BaseShift));
     ret.G_Byte = (byte)((uint)(G_Byte) + ((((uint)(c.G_Byte) - G_Byte) * ik) >> BaseShift));
     ret.B_Byte = (byte)((uint)(B_Byte) + ((((uint)(c.B_Byte) - B_Byte) * ik) >> BaseShift));
     ret.A_Byte = (byte)((uint)(A_Byte) + ((((uint)(c.A_Byte) - A_Byte) * ik) >> BaseShift));
     return ret;
 }
 //-------------------------------------------------------------------------
 public unsafe void pixel(RGBA_Bytes* p, int x, int y)
 {
     m_pattern.pixel(p, x, y);
 }
        line_patterns_application(PixelFormats format, AGG.UI.PlatformSupportAbstract.ERenderOrigin RenderOrigin)
            : base(format, RenderOrigin)
        {
            m_ctrl_color = new RGBA_Bytes(0, 0.3, 0.5, 0.3);
            m_scale_x = new SliderWidget(5.0,   5.0, 240.0, 12.0);
            m_start_x = new SliderWidget(250.0, 5.0, 495.0, 12.0);
            m_approximation_method = new cbox_ctrl(10, 30, "Approximation Method = curve_div");

            m_curve1.line_color(m_ctrl_color);
            m_curve2.line_color(m_ctrl_color);
            m_curve3.line_color(m_ctrl_color);
            m_curve4.line_color(m_ctrl_color);
            m_curve5.line_color(m_ctrl_color);
            m_curve6.line_color(m_ctrl_color);
            m_curve7.line_color(m_ctrl_color);
            m_curve8.line_color(m_ctrl_color);
            m_curve9.line_color(m_ctrl_color);

            m_curve1.curve(64, 19, 14, 126, 118, 266, 19, 265);
            m_curve2.curve(112, 113, 178, 32, 200, 132, 125, 438);
            m_curve3.curve(401, 24, 326, 149, 285, 11, 177, 77);
            m_curve4.curve(188, 427, 129, 295, 19, 283, 25, 410);
            m_curve5.curve(451, 346, 302, 218, 265, 441, 459, 400);
            m_curve6.curve(454, 198, 14, 13, 220, 291, 483, 283);
            m_curve7.curve(301, 398, 355, 231, 209, 211, 170, 353);
            m_curve8.curve(484, 101, 222, 33, 486, 435, 487, 138);
            m_curve9.curve(143, 147, 11, 45, 83, 427, 132, 197);

            AddChild(m_curve1);
            AddChild(m_curve2);
            AddChild(m_curve3);
            AddChild(m_curve4);
            AddChild(m_curve5);
            AddChild(m_curve6);
            AddChild(m_curve7);
            AddChild(m_curve8);
            AddChild(m_curve9);
            AddChild(m_approximation_method);

            m_scale_x.label("Scale X=%.2f");
            m_scale_x.range(0.2, 3.0);
            m_scale_x.value(1.0);
            AddChild(m_scale_x);

            m_start_x.label("Start X=%.2f");
            m_start_x.range(0.0, 10.0);
            m_start_x.value(0.0);
            AddChild(m_start_x);
        }
 //--------------------------------------------------------------------
 public RGBA_Bytes Gradient(RGBA_Bytes c_8, double k)
 {
     RGBA_Doubles c = c_8.GetAsRGBA_Doubles();
     RGBA_Doubles ret;
     ret.m_r = m_r + (c.m_r - m_r) * k;
     ret.m_g = m_g + (c.m_g - m_g) * k;
     ret.m_b = m_b + (c.m_b - m_b) * k;
     ret.m_a = m_a + (c.m_a - m_a) * k;
     return ret.GetAsRGBA_Bytes();
 }
Example #9
0
        public override void Render(IVertexSource vertexSource, int pathIndexToRender, RGBA_Bytes colorBytes)
        {
#if use_timers
            OpenGLRenderTimer.Start();
#endif
            PushOrthoProjection();

            vertexSource.rewind(pathIndexToRender);

            RGBA_Doubles color = colorBytes.GetAsRGBA_Doubles();

            Gl.glColor4d(color.m_r, color.m_g, color.m_b, color.m_a);

            Affine transform = GetTransform();
            if (!transform.is_identity())
            {
                vertexSource = new conv_transform(vertexSource, transform);
            }

            if (m_ForceTexturedEdgeAntiAliasing)
            {
                DrawAAShape(vertexSource);
            }
            else
            {
                SendShapeToTeselator(m_RenderNowTesselator, vertexSource);
            }

            PopOrthoProjection();
#if use_timers
            OpenGLRenderTimer.Stop();
#endif
        }
Example #10
0
        public override void Render(IVertexSource vertexSource, uint pathIndexToRender, RGBA_Bytes colorBytes)
        {
#if use_timers
            OpenGLRenderTimer.Start();
#endif
            PushOrthoProjection();

            vertexSource.rewind(pathIndexToRender);

            RGBA_Doubles color = colorBytes.GetAsRGBA_Doubles();

            Gl.glColor4d(color.m_r, color.m_g, color.m_b, color.m_a);

            m_Tesselator.BeginPolygon();

            uint   PathAndFlags = 0;
            double x, y;
            bool   haveBegunContour = false;
            while (!Path.is_stop(PathAndFlags = vertexSource.vertex(out x, out y)))
            {
                if (Path.is_close(PathAndFlags) ||
                    (haveBegunContour && Path.is_move_to(PathAndFlags)))
                {
                    m_Tesselator.EndContour();
                    haveBegunContour = false;
                }

                if (!Path.is_close(PathAndFlags))
                {
                    if (!haveBegunContour)
                    {
                        m_Tesselator.BeginContour();
                        haveBegunContour = true;
                    }

                    m_Tesselator.AddVertex(x, y);
                }
            }

            if (haveBegunContour)
            {
                m_Tesselator.EndContour();
            }

#if use_timers
            OpenGLEndPolygonTimer.Start();
#endif
            m_Tesselator.EndPolygon();
#if use_timers
            OpenGLEndPolygonTimer.Stop();
#endif

            PopOrthoProjection();
#if use_timers
            OpenGLRenderTimer.Stop();
#endif
        }
Example #11
0
 public override void ToPix(ref RGBA_Bytes c)
 {
     c = new RGBA_Bytes((Byte)Basics.RoundUint(R), c.G, c.B, c.A);
     //c.R = (Byte)Basics.RoundUint(R);
 }
Example #12
0
 public override void FromPix(RGBA_Bytes c)
 {
     R = c.R;
 }
Example #13
0
 public override void FromPix(RGBA_Bytes c)
 {
     R = c.R;
     G = c.G;
     B = c.B;
 }
        //--------------------------------------------------------------------
        public unsafe override void Generate(RGBA_Bytes* span, int x, int y, uint len)
        {
            ISpanInterpolator spanInterpolator = base.Interpolator;
            spanInterpolator.Begin(x + base.FilterDxDbl(), y + 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) >> 
                                         downscale_shift;
                            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)base_mask;

                    ++span;
                    Interpolator.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(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
        }
 public unsafe abstract void Generate(RGBA_Bytes* span, int x, int y, uint len);
 //--------------------------------------------------------------------
 public SpanImageFilterRgbBilinearClip(IRasterBufferAccessor src, 
                                     IColorType back_color,
                                     ISpanInterpolator inter) : base(src, inter, null)
 {
     m_back_color = back_color.GetAsRGBA_Bytes();
     OrderR = src.PixelFormat.Blender.OrderR;
     OrderG = src.PixelFormat.Blender.OrderG;
     OrderB = src.PixelFormat.Blender.OrderB;
     OrderA = src.PixelFormat.Blender.OrderA;
 }
 //--------------------------------------------------------------------
 RGBA_Bytes(RGBA_Bytes c, uint a_)
 {
     m_R = (byte)c.m_R;
     m_G = (byte)c.m_G;
     m_B = (byte)c.m_B;
     m_A = (byte)a_;
 }
 public void background_color(IColorType v) { m_back_color = v.GetAsRGBA_Bytes(); }
 //--------------------------------------------------------------------
 public void Add(RGBA_Bytes c, uint cover)
 {
     uint cr, cg, cb, ca;
     if (cover == CoverMask)
     {
         if (c.A_Byte == BaseMask)
         {
             this = c;
         }
         else
         {
             cr = R_Byte + c.R_Byte; R_Byte = (cr > (uint)(BaseMask)) ? (uint)(BaseMask) : cr;
             cg = G_Byte + c.G_Byte; G_Byte = (cg > (uint)(BaseMask)) ? (uint)(BaseMask) : cg;
             cb = B_Byte + c.B_Byte; B_Byte = (cb > (uint)(BaseMask)) ? (uint)(BaseMask) : cb;
             ca = A_Byte + c.A_Byte; A_Byte = (ca > (uint)(BaseMask)) ? (uint)(BaseMask) : ca;
         }
     }
     else
     {
         cr = R_Byte + ((c.R_Byte * cover + CoverMask / 2) >> CoverShift);
         cg = G_Byte + ((c.G_Byte * cover + CoverMask / 2) >> CoverShift);
         cb = B_Byte + ((c.B_Byte * cover + CoverMask / 2) >> CoverShift);
         ca = A_Byte + ((c.A_Byte * cover + CoverMask / 2) >> CoverShift);
         R_Byte = (cr > (uint)(BaseMask)) ? (uint)(BaseMask) : cr;
         G_Byte = (cg > (uint)(BaseMask)) ? (uint)(BaseMask) : cg;
         B_Byte = (cb > (uint)(BaseMask)) ? (uint)(BaseMask) : cb;
         A_Byte = (ca > (uint)(BaseMask)) ? (uint)(BaseMask) : ca;
     }
 }
        //--------------------------------------------------------------------
        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;

            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 SourceRenderingBuffer = base.Source().PixelFormat.GetRenderingBuffer();
            int maxx = (int)SourceRenderingBuffer.Width - 1;
            int maxy = (int)SourceRenderingBuffer.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.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).m_R = (byte)fg[0];
                    (*span).m_G = (byte)fg[1];
                    (*span).m_B = (byte)fg[2];
                    (*span).m_A = (byte)src_alpha;
                    ++span;
                    spanInterpolator.Next();

                } while(--len != 0);
            }
#if use_timers
            Generate_Span.Stop();
#endif
        }
 //--------------------------------------------------------------------
 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 unsafe override void Generate(RGBA_Bytes* span, int x, int y, uint len)
        {
            base.Interpolator.Begin(x + base.FilterDxDbl(), y + 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 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;
                spanInterpolator.Next();

            } while(--len != 0);
        }
        public override void Render(IVertexSource vertexSource, uint pathIndexToRender, RGBA_Bytes colorBytes)
        {
#if use_timers
            OpenGLRenderTimer.Start();
#endif
            PushOrthoProjection();

            vertexSource.rewind(pathIndexToRender);

            RGBA_Doubles color = colorBytes.GetAsRGBA_Doubles();

            Gl.glColor4d(color.m_r, color.m_g, color.m_b, color.m_a);

            m_Tesselator.BeginPolygon();

            uint PathAndFlags = 0;
            double x, y;
            bool haveBegunContour = false;
            while (!Path.is_stop(PathAndFlags = vertexSource.vertex(out x, out y)))
            {
                if (Path.is_close(PathAndFlags)
                    || (haveBegunContour && Path.is_move_to(PathAndFlags)))
                {
                    m_Tesselator.EndContour();
                    haveBegunContour = false;
                }

                if(!Path.is_close(PathAndFlags))
                {
                    if (!haveBegunContour)
                    {
                        m_Tesselator.BeginContour();
                        haveBegunContour = true;
                    }

                    m_Tesselator.AddVertex(x, y);
                }
            }

            if (haveBegunContour)
            {
                m_Tesselator.EndContour();
            }

#if use_timers
            OpenGLEndPolygonTimer.Start();
#endif
            m_Tesselator.EndPolygon();
#if use_timers
            OpenGLEndPolygonTimer.Stop();
#endif

            PopOrthoProjection();
#if use_timers
            OpenGLRenderTimer.Stop();
#endif
        }
        //--------------------------------------------------------------------
        public unsafe override void Generate(RGBA_Bytes* span, int x, int y, uint len)
        {
            ISpanInterpolator spanInterpolator = base.Interpolator;
            spanInterpolator.Begin(x + base.FilterDxDbl(), y + 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;
                    spanInterpolator.Next();

                } while (--len != 0);
            }
        }
Example #26
0
 public override void Render(IImage source,
     double x, double y,
     double angleDegrees,
     double scaleX, double ScaleY,
     RGBA_Bytes color,
     BlendMode renderingMode)
 {
     ImageGL
     x = 0;
 }
Example #27
0
 public abstract void FromPix(RGBA_Bytes c);