示例#1
0
 public override void Render(IVertexSource vertexSource, int pathIndexToRender, RGBA_Bytes colorBytes)
 {
     m_Rasterizer.reset();
     Affine transform = GetTransform();
     if (!transform.IsIdentity())
     {
         vertexSource = new conv_transform(vertexSource, transform);
     }
     m_Rasterizer.add_path(vertexSource, pathIndexToRender);
     Renderer.RenderSolid(m_DestImage, m_Rasterizer, m_ScanlineCache, colorBytes);
 }
 public override void generate(RGBA_Bytes[] span, int spanIndex, int x, int y, int len)
 {
     IImage SourceRenderingBuffer = base.source().DestImage;
     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.image_subpixel_shift;
         int y_lr = y_hr >> (int)image_subpixel_scale_e.image_subpixel_shift;
         int bufferIndex;
         byte[] fg_ptr = SourceRenderingBuffer.GetPixelPointerXY(y_lr, x_lr, out bufferIndex);
         span[spanIndex].m_R = fg_ptr[ImageBuffer.OrderR];
         span[spanIndex].m_G = fg_ptr[ImageBuffer.OrderG];
         span[spanIndex].m_B = fg_ptr[ImageBuffer.OrderB];
         span[spanIndex].m_A = fg_ptr[ImageBuffer.OrderA];
         ++spanIndex;
         spanInterpolator.Next();
     } while (--len != 0);
 }
示例#3
0
 public void Render(IVertexSource vertexSource, RGBA_Bytes[] colorArray, int[] pathIdArray, int numPaths)
 {
     for (int i = 0; i < numPaths; i++)
     {
         Render(vertexSource, pathIdArray[i], colorArray[i]);
     }
 }
示例#4
0
 //--------------------------------------------------------------------
 public RGBA_Bytes gradient(RGBA_Bytes c, double k)
 {
     RGBA_Bytes ret = new RGBA_Bytes();
     int ik = agg_basics.uround(k * base_scale);
     ret.R_Byte = (byte)((int)(R_Byte) + ((((int)(c.R_Byte) - R_Byte) * ik) >> base_shift));
     ret.G_Byte = (byte)((int)(G_Byte) + ((((int)(c.G_Byte) - G_Byte) * ik) >> base_shift));
     ret.B_Byte = (byte)((int)(B_Byte) + ((((int)(c.B_Byte) - B_Byte) * ik) >> base_shift));
     ret.A_Byte = (byte)((int)(A_Byte) + ((((int)(c.A_Byte) - A_Byte) * ik) >> base_shift));
     return ret;
 }
示例#5
0
 //--------------------------------------------------------------------
 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();
 }
            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];
                }
            }
 public void background_color(IColorType v) { m_OutsideSourceColor = v.GetAsRGBA_Bytes(); }
示例#8
0
 public abstract void generate(RGBA_Bytes[] span, int spanIndex, int x, int y, int len);
示例#9
0
        public override void copy_vline(int x, int y1, int y2, RGBA_Bytes c)
        {
            if (y1 > y2) { int t = (int)y2; y2 = (int)y1; y1 = t; }
            if (x > xmax()) return;
            if (x < xmin()) return;
            if (y1 > ymax()) return;
            if (y2 < ymin()) return;

            if (y1 < ymin()) y1 = ymin();
            if (y2 > ymax()) y2 = (int)ymax();

            base.copy_vline(x, y1, (int)(y2 - y1 + 1), c);
        }
示例#10
0
        public override void copy_hline(int x1, int y, int x2, RGBA_Bytes c)
        {
            if (x1 > x2) { int t = (int)x2; x2 = (int)x1; x1 = t; }
            if (y > ymax()) return;
            if (y < ymin()) return;
            if (x1 > xmax()) return;
            if (x2 < xmin()) return;

            if (x1 < xmin()) x1 = xmin();
            if (x2 > xmax()) x2 = (int)xmax();

            base.copy_hline(x1, y, (int)(x2 - x1 + 1), c);
        }
示例#11
0
 public abstract void Render(IImage imageSource,
     double x, double y,
     double angleDegrees,
     double scaleX, double ScaleY,
     RGBA_Bytes color,
     bool doDrawing,
     bool oneMinusSourceAlphaOne);
示例#12
0
 public abstract void Render(IVertexSource vertexSource, int pathIndexToRender, RGBA_Bytes colorBytes);
示例#13
0
 public void Line(double x1, double y1, double x2, double y2, RGBA_Bytes color)
 {
     PathStorage m_LinesToDraw = new PathStorage();
     m_LinesToDraw.Clear();
     m_LinesToDraw.MoveTo(x1, y1);
     m_LinesToDraw.LineTo(x2, y2);
     conv_stroke StrockedLineToDraw = new conv_stroke(m_LinesToDraw);
     Render(StrockedLineToDraw, color);
 }
示例#14
0
 public void Line(Vector2D Start, Vector2D End, RGBA_Bytes color)
 {
     Line(Start.x, Start.y, End.x, End.y, color);
 }
示例#15
0
 public void Render(IVertexSource vertexSource, RGBA_Bytes color)
 {
     Render(vertexSource, 0, color);
 }
示例#16
0
        public override void blend_color_vspan(int x, int y, int len, RGBA_Bytes[] colors, int colorsIndex, byte[] covers, int coversIndex, bool firstCoverForAll)
        {
            if (x > xmax()) return;
            if (x < xmin()) return;

            if (y < ymin())
            {
                int d = ymin() - y;
                len -= d;
                if (len <= 0) return;
                if (covers != null) coversIndex += d;
                colorsIndex += d;
                y = ymin();
            }
            if (y + len > ymax())
            {
                len = (ymax() - y + 1);
                if (len <= 0) return;
            }
            base.blend_color_vspan(x, y, len, colors, colorsIndex, covers, coversIndex, firstCoverForAll);
        }
示例#17
0
 public void clear(IColorType in_c)
 {
     int y;
     RGBA_Bytes c = new RGBA_Bytes(in_c.R_Byte, in_c.G_Byte, in_c.B_Byte, in_c.A_Byte);
     if (Width() != 0)
     {
         for (y = 0; y < Height(); y++)
         {
             base.copy_hline(0, (int)y, (int)Width(), c);
         }
     }
 }
示例#18
0
        public override void blend_hline(int x1, int y, int x2, RGBA_Bytes c, byte cover)
        {
            if (x1 > x2)
            {
                int t = (int)x2;
                x2 = x1;
                x1 = t;
            }
            if (y > ymax())
                return;
            if (y < ymin())
                return;
            if (x1 > xmax())
                return;
            if (x2 < xmin())
                return;

            if (x1 < xmin())
                x1 = xmin();
            if (x2 > xmax())
                x2 = xmax();

            base.blend_hline(x1, y, x2, c, cover);
        }
        public override void generate(RGBA_Bytes[] span, int spanIndex, int x, int y, int len)
        {
            throw new NotImplementedException(); /*
#if use_timers
                Generate_Span.Start();
#endif
                base.interpolator().begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), len);

                byte[] fg = stackalloc int[4];

                IImage sourceImage = source().DestImage;
                byte[] fg_ptr = sourceImage.ByteBuffer;

                int maxx = (int)sourceImage.Width() - 1;
                int maxy = (int)sourceImage.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.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 = sourceImage.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 = sourceImage.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;

                        (*span).m_R = (byte)fg[OrderR];
                        (*span).m_G = (byte)fg[OrderG];
                        (*span).m_B = (byte)fg[ImageBuffer.OrderB];
                        (*span).m_A = (byte)fg[OrderA];
                        ++span;
                        spanInterpolator.Next();

                    } while (--len != 0);
                }
#if use_timers
                Generate_Span.Stop();
#endif
                                                      */
        }
示例#20
0
        public override void blend_vline(int x, int y1, int y2, RGBA_Bytes c, byte cover)
        {
            if (y1 > y2) { int t = y2; y2 = y1; y1 = t; }
            if (x > xmax()) return;
            if (x < xmin()) return;
            if (y1 > ymax()) return;
            if (y2 < ymin()) return;

            if (y1 < ymin()) y1 = ymin();
            if (y2 > ymax()) y2 = ymax();

            base.blend_vline(x, y1, y2, c, cover);
        }
 public span_image_filter_rgba_bilinear_clip(IImageBufferAccessor src,
     IColorType back_color, ISpanInterpolator inter)
     : base(src, inter, null)
 {
     m_OutsideSourceColor = back_color.GetAsRGBA_Bytes();
 }
示例#22
0
        /*
        public void copy_bar(int x1, int y1, int x2, int y2, IColorType c)
        {
            rect_i rc(x1, y1, x2, y2);
            rc.normalize();
            if(rc.clip(clip_box()))
            {
                int y;
                for(y = rc.y1; y <= rc.y2; y++)
                {
                    m_ren->copy_hline(rc.x1, y, int(rc.x2 - rc.x1 + 1), c);
                }
            }
        }

        public void blend_bar(int x1, int y1, int x2, int y2, 
                       IColorType c, byte cover)
        {
            rect_i rc(x1, y1, x2, y2);
            rc.normalize();
            if(rc.clip(clip_box()))
            {
                int y;
                for(y = rc.y1; y <= rc.y2; y++)
                {
                    m_ren->blend_hline(rc.x1,
                                       y,
                                       int(rc.x2 - rc.x1 + 1), 
                                       c, 
                                       cover);
                }
            }
        }
         */

        public override void blend_solid_hspan(int x, int y, int in_len, RGBA_Bytes c, byte[] covers, int coversIndex)
        {
            int len = (int)in_len;
            if (y > ymax()) return;
            if (y < ymin()) return;

            if (x < xmin())
            {
                len -= xmin() - x;
                if (len <= 0) return;
                coversIndex += xmin() - x;
                x = xmin();
            }
            if (x + len > xmax())
            {
                len = xmax() - x + 1;
                if (len <= 0) return;
            }
            base.blend_solid_hspan(x, y, len, c, covers, coversIndex);
        }
        public override void generate(RGBA_Bytes[] span, int spanIndex, int x, int y, int len)
        {
            /*#if use_timers
                        Generate_Span.Start();
            #endif*/
            base.interpolator().begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), len);

            int[] accumulatedColor = new int[4];

            int back_r = m_OutsideSourceColor.m_R;
            int back_g = m_OutsideSourceColor.m_G;
            int back_b = m_OutsideSourceColor.m_B;
            int back_a = m_OutsideSourceColor.m_A;

            int bufferIndex;
            byte[] fg_ptr;

            ImageBuffer SourceRenderingBuffer = (ImageBuffer)base.source().DestImage;
            int distanceBetweenPixelsInclusive = base.source().DestImage.GetDistanceBetweenPixelsInclusive();
            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.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;

                    if (x_lr >= 0 && y_lr >= 0 &&
                       x_lr < maxx && y_lr < maxy)
                    {
                        accumulatedColor[0] =
                        accumulatedColor[1] =
                        accumulatedColor[2] =
                        accumulatedColor[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 = SourceRenderingBuffer.GetPixelPointerXY(x_lr, y_lr, out bufferIndex);

                        weight = (((int)image_subpixel_scale_e.image_subpixel_scale - x_hr) *
                                 ((int)image_subpixel_scale_e.image_subpixel_scale - y_hr));
                        accumulatedColor[0] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderR];
                        accumulatedColor[1] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderG];
                        accumulatedColor[2] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderB];
                        accumulatedColor[3] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderA];

                        bufferIndex += distanceBetweenPixelsInclusive;
                        weight = (x_hr * ((int)image_subpixel_scale_e.image_subpixel_scale - y_hr));
                        accumulatedColor[0] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderR];
                        accumulatedColor[1] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderG];
                        accumulatedColor[2] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderB];
                        accumulatedColor[3] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderA];

                        ++y_lr;
                        fg_ptr = SourceRenderingBuffer.GetPixelPointerXY(x_lr, y_lr, out bufferIndex);

                        weight = (((int)image_subpixel_scale_e.image_subpixel_scale - x_hr) * y_hr);
                        accumulatedColor[0] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderR];
                        accumulatedColor[1] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderG];
                        accumulatedColor[2] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderB];
                        accumulatedColor[3] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderA];

                        bufferIndex += distanceBetweenPixelsInclusive;
                        weight = (x_hr * y_hr);
                        accumulatedColor[0] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderR];
                        accumulatedColor[1] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderG];
                        accumulatedColor[2] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderB];
                        accumulatedColor[3] += weight * fg_ptr[bufferIndex + ImageBuffer.OrderA];

                        accumulatedColor[0] >>= (int)image_subpixel_scale_e.image_subpixel_shift * 2;
                        accumulatedColor[1] >>= (int)image_subpixel_scale_e.image_subpixel_shift * 2;
                        accumulatedColor[2] >>= (int)image_subpixel_scale_e.image_subpixel_shift * 2;
                        accumulatedColor[3] >>= (int)image_subpixel_scale_e.image_subpixel_shift * 2;
                    }
                    else
                    {
                        if (x_lr < -1 || y_lr < -1 ||
                           x_lr > maxx || y_lr > maxy)
                        {
                            accumulatedColor[0] = back_r;
                            accumulatedColor[1] = back_g;
                            accumulatedColor[2] = back_b;
                            accumulatedColor[3] = back_a;
                        }
                        else
                        {
                            accumulatedColor[0] =
                            accumulatedColor[1] =
                            accumulatedColor[2] =
                            accumulatedColor[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;

                            weight = (((int)image_subpixel_scale_e.image_subpixel_scale - x_hr) *
                                     ((int)image_subpixel_scale_e.image_subpixel_scale - y_hr));
                            BlendInFilterPixel(accumulatedColor, back_r, back_g, back_b, back_a, SourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight);

                            x_lr++;

                            weight = (x_hr * ((int)image_subpixel_scale_e.image_subpixel_scale - y_hr));
                            BlendInFilterPixel(accumulatedColor, back_r, back_g, back_b, back_a, SourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight);

                            x_lr--;
                            y_lr++;

                            weight = (((int)image_subpixel_scale_e.image_subpixel_scale - x_hr) * y_hr);
                            BlendInFilterPixel(accumulatedColor, back_r, back_g, back_b, back_a, SourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight);

                            x_lr++;

                            weight = (x_hr * y_hr);
                            BlendInFilterPixel(accumulatedColor, back_r, back_g, back_b, back_a, SourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight);

                            accumulatedColor[0] >>= (int)image_subpixel_scale_e.image_subpixel_shift * 2;
                            accumulatedColor[1] >>= (int)image_subpixel_scale_e.image_subpixel_shift * 2;
                            accumulatedColor[2] >>= (int)image_subpixel_scale_e.image_subpixel_shift * 2;
                            accumulatedColor[3] >>= (int)image_subpixel_scale_e.image_subpixel_shift * 2;
                        }
                    }

                    span[spanIndex].m_R = (byte)accumulatedColor[0];
                    span[spanIndex].m_G = (byte)accumulatedColor[1];
                    span[spanIndex].m_B = (byte)accumulatedColor[2];
                    span[spanIndex].m_A = (byte)accumulatedColor[3];
                    ++spanIndex;
                    spanInterpolator.Next();
                } while (--len != 0);
            }
#if use_timers
                Generate_Span.Stop();
#endif
        }
示例#24
0
        public override void blend_solid_vspan(int x, int y, int len, RGBA_Bytes c, byte[] covers, int coversIndex)
        {
            if (x > xmax()) return;
            if (x < xmin()) return;

            if (y < ymin())
            {
                len -= (ymin() - y);
                if (len <= 0) return;
                coversIndex += ymin() - y;
                y = ymin();
            }
            if (y + len > ymax())
            {
                len = (ymax() - y + 1);
                if (len <= 0) return;
            }
            base.blend_solid_vspan(x, y, len, c, covers, coversIndex);
        }
        //--------------------------------------------------------------------
        public override void generate(RGBA_Bytes[] span, int spanIndex, int x, int y, int len)
        {
            ISpanInterpolator spanInterpolator = base.interpolator();
            spanInterpolator.begin(x + base.filter_dx_dbl(), y + base.filter_dy_dbl(), len);

            int[] fg = new int[4];

            byte[] fg_ptr;
            int[] weightArray = filter().weight_array();
            int diameter = (int)base.filter().diameter();
            int filter_scale = diameter << (int)image_subpixel_scale_e.image_subpixel_shift;

            int[] weight_array = weightArray;

            do
            {
                int rx;
                int ry;
                int rx_inv = (int)image_subpixel_scale_e.image_subpixel_scale;
                int ry_inv = (int)image_subpixel_scale_e.image_subpixel_scale;
                spanInterpolator.coordinates(out x, out y);
                spanInterpolator.local_scale(out rx, out ry);
                base.adjust_scale(ref rx, ref ry);

                rx_inv = (int)image_subpixel_scale_e.image_subpixel_scale * (int)image_subpixel_scale_e.image_subpixel_scale / rx;
                ry_inv = (int)image_subpixel_scale_e.image_subpixel_scale * (int)image_subpixel_scale_e.image_subpixel_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.image_subpixel_mask) >>
                        (int)(int)image_subpixel_scale_e.image_subpixel_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.image_filter_scale / 2;

                int y_lr = y >> (int)(int)image_subpixel_scale_e.image_subpixel_shift;
                int y_hr = (((int)image_subpixel_scale_e.image_subpixel_mask - (y & (int)image_subpixel_scale_e.image_subpixel_mask)) *
                               ry_inv) >> (int)(int)image_subpixel_scale_e.image_subpixel_shift;
                int total_weight = 0;
                int x_lr = x >> (int)(int)image_subpixel_scale_e.image_subpixel_shift;
                int x_hr = (((int)image_subpixel_scale_e.image_subpixel_mask - (x & (int)image_subpixel_scale_e.image_subpixel_mask)) *
                               rx_inv) >> (int)(int)image_subpixel_scale_e.image_subpixel_shift;
                int x_hr2 = x_hr;
                int sourceIndex;
                fg_ptr = base.source().span(x_lr, y_lr, len_x_lr, out sourceIndex);

                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.image_filter_scale / 2) >>
                                     downscale_shift;
                        fg[0] += fg_ptr[sourceIndex + ImageBuffer.OrderR] * weight;
                        fg[1] += fg_ptr[sourceIndex + ImageBuffer.OrderG] * weight;
                        fg[2] += fg_ptr[sourceIndex + ImageBuffer.OrderB] * weight;
                        fg[3] += fg_ptr[sourceIndex + ImageBuffer.OrderA] * weight;
                        total_weight += weight;
                        x_hr += rx_inv;
                        if (x_hr >= filter_scale) break;
                        fg_ptr = base.source().next_x(out sourceIndex);
                    }
                    y_hr += ry_inv;
                    if (y_hr >= filter_scale)
                    {
                        break;
                    }

                    fg_ptr = base.source().next_y(out sourceIndex);
                }

                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] > base_mask) fg[0] = base_mask;
                if (fg[1] > base_mask) fg[1] = base_mask;
                if (fg[2] > base_mask) fg[2] = base_mask;
                if (fg[3] > base_mask) fg[3] = base_mask;

                span[spanIndex].m_R = (byte)fg[0];
                span[spanIndex].m_G = (byte)fg[1];
                span[spanIndex].m_B = (byte)fg[2];
                span[spanIndex].m_A = (byte)fg[3];

                spanIndex++;
                interpolator().Next();
            } while (--len != 0);
        }
示例#26
0
        public override void copy_color_hspan(int x, int y, int len, RGBA_Bytes[] colors, int colorsIndex)
        {
            if (y > ymax()) return;
            if (y < ymin()) return;

            if (x < xmin())
            {
                int d = xmin() - x;
                len -= d;
                if (len <= 0) return;
                colorsIndex += d;
                x = xmin();
            }
            if (x + len > xmax())
            {
                len = (xmax() - x + 1);
                if (len <= 0) return;
            }
            base.copy_color_hspan(x, y, len, colors, colorsIndex);
        }
示例#27
0
 //--------------------------------------------------------------------
 RGBA_Bytes(RGBA_Bytes c, int a_)
 {
     m_R = (byte)c.m_R;
     m_G = (byte)c.m_G;
     m_B = (byte)c.m_B;
     m_A = (byte)a_;
 }
示例#28
0
        public override void copy_color_vspan(int x, int y, int len, RGBA_Bytes[] colors, int colorsIndex)
        {
            if (x > xmax()) return;
            if (x < xmin()) return;

            if (y < ymin())
            {
                int d = ymin() - y;
                len -= d;
                if (len <= 0) return;
                colorsIndex += d;
                y = ymin();
            }
            if (y + len > ymax())
            {
                len = (ymax() - y + 1);
                if (len <= 0) return;
            }
            base.copy_color_vspan(x, y, len, colors, colorsIndex);
        }
示例#29
0
 //--------------------------------------------------------------------
 public void add(RGBA_Bytes c, int cover)
 {
     int cr, cg, cb, ca;
     if (cover == cover_mask)
     {
         if (c.A_Byte == base_mask)
         {
             this = c;
         }
         else
         {
             cr = R_Byte + c.R_Byte; R_Byte = (cr > (int)(base_mask)) ? (int)(base_mask) : cr;
             cg = G_Byte + c.G_Byte; G_Byte = (cg > (int)(base_mask)) ? (int)(base_mask) : cg;
             cb = B_Byte + c.B_Byte; B_Byte = (cb > (int)(base_mask)) ? (int)(base_mask) : cb;
             ca = A_Byte + c.A_Byte; A_Byte = (ca > (int)(base_mask)) ? (int)(base_mask) : ca;
         }
     }
     else
     {
         cr = R_Byte + ((c.R_Byte * cover + cover_mask / 2) >> cover_shift);
         cg = G_Byte + ((c.G_Byte * cover + cover_mask / 2) >> cover_shift);
         cb = B_Byte + ((c.B_Byte * cover + cover_mask / 2) >> cover_shift);
         ca = A_Byte + ((c.A_Byte * cover + cover_mask / 2) >> cover_shift);
         R_Byte = (cr > (int)(base_mask)) ? (int)(base_mask) : cr;
         G_Byte = (cg > (int)(base_mask)) ? (int)(base_mask) : cg;
         B_Byte = (cb > (int)(base_mask)) ? (int)(base_mask) : cb;
         A_Byte = (ca > (int)(base_mask)) ? (int)(base_mask) : ca;
     }
 }
示例#30
0
        public override void blend_color_hspan(int x, int y, int in_len, RGBA_Bytes[] colors, int colorsIndex, byte[] covers, int coversIndex, bool firstCoverForAll)
        {
            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) coversIndex += d;
                colorsIndex += d;
                x = xmin();
            }
            if (x + len - 1 > xmax())
            {
                len = xmax() - x + 1;
                if (len <= 0) return;
            }

            base.blend_color_hspan(x, y, len, colors, colorsIndex, covers, coversIndex, firstCoverForAll);
        }