Beispiel #1
0
 ///<summary>
 ///</summary>
 ///<param name="pixf"></param>
 ///<param name="mask"></param>
 public AlphaMaskAdaptor(IPixelFormat pixf, IAlphaMask mask)
     : base(pixf)
 {
     PixelFormat = pixf;
     _alphaMask = mask;
     _span = new ArrayPOD<byte>(255);
 }
		public AlphaMaskAdaptor(IImageByte image, IAlphaMask mask)
			: base(image)
		{
			linkedImage = image;
			m_mask = mask;
			m_span = new ArrayPOD<byte>(255);
		}
Beispiel #3
0
 public AlphaMaskAdaptor(IImageByte image, IAlphaMask mask)
     : base(image)
 {
     linkedImage = image;
     m_mask      = mask;
     m_span      = new ArrayPOD <byte>(255);
 }
Beispiel #4
0
        //------------------------------------------------------------------------
        public void Prepare()
        {
            if (m_num > 2)
            {
                int i, k;
                int r;
                int s;
                T   h, p, d, f, e;

                for (k = 0; k < m_num; k++)
                {
                    m_am[k] = M.Zero <T>();
                }

                int n1 = 3 * m_num;

                ArrayPOD <T> al = new ArrayPOD <T>(n1);

                for (k = 0; k < n1; k++)
                {
                    al[k] = M.Zero <T>();
                }

                r = m_num;
                s = m_num * 2;

                n1 = m_num - 1;
                d  = m_am[m_xOffset + 1].Subtract(m_am[m_xOffset + 0]);
                e  = m_am[m_yOffset + 1].Subtract(m_am[m_yOffset + 0]).Divide(d);

                for (k = 1; k < n1; k++)
                {
                    h         = d;
                    d         = m_am[m_xOffset + k + 1].Subtract(m_am[m_xOffset + k]);
                    f         = e;
                    e         = m_am[m_yOffset + k + 1].Subtract(m_am[m_yOffset + k]).Divide(d);
                    al[k]     = d.Divide(d.Add(h));
                    al[r + k] = M.One <T>().Subtract(al[k]);
                    al[s + k] = M.New <T>(6.0).Multiply(e.Subtract(f).Divide(h.Add(d)));
                }

                for (k = 1; k < n1; k++)
                {
                    p = M.One <T>().Divide(al[r + k].Multiply(al[k - 1]).Add(2.0));
                    al[k].MultiplyEquals(p.Negative());
                    al[s + k] = al[s + k].Subtract(al[r + k].Multiply(al[s + k - 1])).Multiply(p);
                }

                m_am[n1]     = M.Zero <T>();
                al[n1 - 1]   = al[s + n1 - 1];
                m_am[n1 - 1] = al[n1 - 1];

                for (k = n1 - 2, i = 0; i < m_num - 2; i++, k--)
                {
                    al[k]   = al[k].Multiply(al[k + 1]).Add(al[s + k]);
                    m_am[k] = al[k];
                }
            }
            m_last_idx = -1;
        }
Beispiel #5
0
 public AlphaMaskAdaptor(IPixelFormat pixf, IAlphaMask mask)
     : base(pixf)
 {
     m_pixf = pixf;
     m_mask = mask;
     m_span = new ArrayPOD <byte>(255);
 }
Beispiel #6
0
        //------------------------------------------------------------------------
        public void prepare()
        {
            if (m_num > 2)
            {
                int    i, k;
                int    r;
                int    s;
                double h, p, d, f, e;

                for (k = 0; k < m_num; k++)
                {
                    m_am[k] = 0.0;
                }

                int n1 = 3 * m_num;

                ArrayPOD <double> al = new ArrayPOD <double>(n1);

                for (k = 0; k < n1; k++)
                {
                    al[k] = 0.0;
                }

                r = m_num;
                s = m_num * 2;

                n1 = m_num - 1;
                d  = m_am[m_xOffset + 1] - m_am[m_xOffset + 0];
                e  = (m_am[m_yOffset + 1] - m_am[m_yOffset + 0]) / d;

                for (k = 1; k < n1; k++)
                {
                    h         = d;
                    d         = m_am[m_xOffset + k + 1] - m_am[m_xOffset + k];
                    f         = e;
                    e         = (m_am[m_yOffset + k + 1] - m_am[m_yOffset + k]) / d;
                    al[k]     = d / (d + h);
                    al[r + k] = 1.0 - al[k];
                    al[s + k] = 6.0 * (e - f) / (h + d);
                }

                for (k = 1; k < n1; k++)
                {
                    p         = 1.0 / (al[r + k] * al[k - 1] + 2.0);
                    al[k]    *= -p;
                    al[s + k] = (al[s + k] - al[r + k] * al[s + k - 1]) * p;
                }

                m_am[n1]     = 0.0;
                al[n1 - 1]   = al[s + n1 - 1];
                m_am[n1 - 1] = al[n1 - 1];

                for (k = n1 - 2, i = 0; i < m_num - 2; i++, k--)
                {
                    al[k]   = al[k] * al[k + 1] + al[s + k];
                    m_am[k] = al[k];
                }
            }
            m_last_idx = -1;
        }
Beispiel #7
0
 public ImageFilterLookUpTable()
 {
     m_weight_array = new ArrayPOD<int>(256);
     m_radius = (0);
     m_diameter = (0);
     m_start = (0);
 }
Beispiel #8
0
 public ImageFilterLookUpTable()
 {
     m_weight_array = new ArrayPOD <short>(256);
     m_radius       = M.Zero <T>();
     m_diameter     = (0);
     m_start        = (0);
 }
Beispiel #9
0
 public Scanline()
 {
     m_last_x = 0x7FFFFFF0;
     m_covers = new ArrayPOD<byte>(1000);
     //m_cover_ptr = null;
     m_spans = new ArrayPOD<ScanlineSpan>(1000);
     //m_cur_span = null;
 }
Beispiel #10
0
 public Scanline()
 {
     m_last_x = 0x7FFFFFF0;
     m_covers = new ArrayPOD <byte>(1000);
     //m_cover_ptr = null;
     m_spans = new ArrayPOD <ScanlineSpan>(1000);
     //m_cur_span = null;
 }
Beispiel #11
0
 public polygon_ctrl_impl(uint np, T point_radius)
     : base(M.Zero <T>(), M.Zero <T>(), M.One <T>(), M.One <T>())
 {
     m_ellipse          = new Ellipse <T>();
     m_polygon          = new ArrayPOD <T>(np * 2);
     m_num_points       = (np);
     m_node             = (-1);
     m_edge             = (-1);
     m_vs               = new simple_polygon_vertex_source <T>(m_polygon.Array, m_num_points, false);
     m_stroke           = new ConvStroke <T>(m_vs);
     m_point_radius     = (point_radius);
     m_status           = (0);
     m_dx               = M.Zero <T>();
     m_dy               = M.Zero <T>();
     m_in_polygon_check = (true);
     m_stroke.Width     = M.One <T>();
 }
Beispiel #12
0
 public polygon_ctrl_impl(int np, double point_radius)
     : base(new Vector2())
 {
     m_ellipse          = new MatterHackers.Agg.VertexSource.Ellipse();
     m_polygon          = new ArrayPOD <double>(np * 2);
     m_num_points       = (np);
     m_node             = (-1);
     m_edge             = (-1);
     m_vs               = new simple_polygon_vertex_source(m_polygon.Array, m_num_points, false);
     m_stroke           = new Stroke(m_vs);
     m_point_radius     = (point_radius);
     m_status           = (0);
     m_dx               = (0.0);
     m_dy               = (0.0);
     m_in_polygon_check = (true);
     m_stroke.width(1.0);
 }
 //--------------------------------------------------------------------
 public ScanlineUnpacked8()
 {
     m_last_x = (0x7FFFFFF0);
     m_covers = new ArrayPOD<byte>(1000);
     m_spans = new ArrayPOD<ScanlineSpan>(1000);
 }
Beispiel #14
0
        public static void RenderCompound(RasterizerCompoundAA<T> ras,
                                       IScanlineCache sl_aa,
                                       IScanlineCache sl_bin,
                                       IPixelFormat pixelFormat,
                                       SpanAllocator alloc,
                                       IStyleHandler sh)
        {
#if true
            unsafe
            {
                if (ras.RewindScanlines())
                {
                    int min_x = ras.MinX;
                    int len = ras.MaxX - min_x + 2;
                    sl_aa.Reset(min_x, ras.MaxX);
                    sl_bin.Reset(min_x, ras.MaxX);

                    //typedef typename BaseRenderer::color_type color_type;
                    ArrayPOD<RGBA_Bytes> color_span = alloc.Allocate((uint)len * 2);
                    byte[] ManagedCoversArray = sl_aa.Covers;
                    fixed (byte* pCovers = ManagedCoversArray)
                    {
                        fixed (RGBA_Bytes* pColorSpan = color_span.Array)
                        {
                            int mix_bufferOffset = len;
                            uint num_spans;

                            uint num_styles;
                            uint style;
                            bool solid;
                            while ((num_styles = ras.SweepStyles()) > 0)
                            {
                                if (num_styles == 1)
                                {
                                    // Optimization for a single style. Happens often
                                    //-------------------------
                                    if (ras.SweepScanline(sl_aa, 0))
                                    {
                                        style = ras.Style(0);
                                        if (sh.IsSolid(style))
                                        {
                                            // Just solid fill
                                            //-----------------------
                                            RenderSolidSingleScanLine(pixelFormat, sl_aa, sh.Color(style));
                                        }
                                        else
                                        {
                                            // Arbitrary span generator
                                            //-----------------------
                                            ScanlineSpan span_aa = sl_aa.Begin();
                                            num_spans = sl_aa.NumSpans;
                                            for (; ; )
                                            {
                                                len = span_aa.Len;
                                                sh.GenerateSpan(pColorSpan,
                                                                 span_aa.X,
                                                                 sl_aa.Y,
                                                                 (uint)len,
                                                                 style);

                                                pixelFormat.BlendColorHSpan(span_aa.X,
                                                                      sl_aa.Y,
                                                                      (uint)span_aa.Len,
                                                                      pColorSpan,
                                                                      &pCovers[span_aa.CoverIndex], 0);
                                                if (--num_spans == 0) break;
                                                span_aa = sl_aa.GetNextScanlineSpan();
                                            }
                                        }
                                    }
                                }
                                else // there are multiple styles
                                {
                                    if (ras.SweepScanline(sl_bin, -1))
                                    {
                                        // Clear the spans of the mix_buffer
                                        //--------------------
                                        ScanlineSpan span_bin = sl_bin.Begin();
                                        num_spans = sl_bin.NumSpans;
                                        for (; ; )
                                        {
                                            Basics.MemClear((byte*)&pColorSpan[mix_bufferOffset + span_bin.X - min_x],
                                                   span_bin.Len * sizeof(RGBA_Bytes));

                                            if (--num_spans == 0) break;
                                            span_bin = sl_bin.GetNextScanlineSpan();
                                        }

                                        for (uint i = 0; i < num_styles; i++)
                                        {
                                            style = ras.Style(i);
                                            solid = sh.IsSolid(style);

                                            if (ras.SweepScanline(sl_aa, (int)i))
                                            {
                                                //IColorType* colors;
                                                //IColorType* cspan;
                                                //typename ScanlineAA::cover_type* covers;
                                                ScanlineSpan span_aa = sl_aa.Begin();
                                                num_spans = sl_aa.NumSpans;
                                                if (solid)
                                                {
                                                    // Just solid fill
                                                    //-----------------------
                                                    for (; ; )
                                                    {
                                                        RGBA_Bytes c = sh.Color(style);
                                                        len = span_aa.Len;
                                                        RGBA_Bytes* colors = &pColorSpan[mix_bufferOffset + span_aa.X - min_x];
                                                        byte* covers = &pCovers[span_aa.CoverIndex];
                                                        do
                                                        {
                                                            if (*covers == CoverFull)
                                                            {
                                                                *colors = c;
                                                            }
                                                            else
                                                            {
                                                                colors->Add(c, *covers);
                                                            }
                                                            ++colors;
                                                            ++covers;
                                                        }
                                                        while (--len != 0);
                                                        if (--num_spans == 0) break;
                                                        span_aa = sl_aa.GetNextScanlineSpan();
                                                    }
                                                }
                                                else
                                                {
                                                    // Arbitrary span generator
                                                    //-----------------------
                                                    for (; ; )
                                                    {
                                                        len = span_aa.Len;
                                                        RGBA_Bytes* colors = &pColorSpan[mix_bufferOffset + span_aa.X - min_x];
                                                        RGBA_Bytes* cspan = pColorSpan;
                                                        sh.GenerateSpan(cspan,
                                                                         span_aa.X,
                                                                         sl_aa.Y,
                                                                         (uint)len,
                                                                         style);
                                                        byte* covers = &pCovers[span_aa.CoverIndex];
                                                        do
                                                        {
                                                            if (*covers == CoverFull)
                                                            {
                                                                *colors = *cspan;
                                                            }
                                                            else
                                                            {
                                                                colors->Add(*cspan, *covers);
                                                            }
                                                            ++cspan;
                                                            ++colors;
                                                            ++covers;
                                                        }
                                                        while (--len != 0);
                                                        if (--num_spans == 0) break;
                                                        span_aa = sl_aa.GetNextScanlineSpan();
                                                    }
                                                }
                                            }
                                        }

                                        // Emit the blended result as a color hspan
                                        //-------------------------
                                        span_bin = sl_bin.Begin();
                                        num_spans = sl_bin.NumSpans;
                                        for (; ; )
                                        {
                                            pixelFormat.BlendColorHSpan(span_bin.X,
                                                                  sl_bin.Y,
                                                                  (uint)span_bin.Len,
                                                                  &pColorSpan[mix_bufferOffset + span_bin.X - min_x],
                                                                  null,
                                                                  CoverFull);
                                            if (--num_spans == 0) break;
                                            span_bin = sl_bin.GetNextScanlineSpan();
                                        }
                                    } // if(ras.sweep_scanline(sl_bin, -1))
                                } // if(num_styles == 1) ... else
                            } // while((num_styles = ras.sweep_styles()) > 0)
                        }
                    }
                } // if(ras.rewind_scanlines())
#endif
            }
        }
Beispiel #15
0
 public ImageFilterLookUpTable(IImageFilterFunction filter, bool normalization)
 {
     m_weight_array = new ArrayPOD<int>(256);
     calculate(filter, normalization);
 }
 //--------------------------------------------------------------------
 public UnpackedScanline()
 {
     m_last_x = (0x7FFFFFF0);
     m_covers = new ArrayPOD <byte>(1000);
     m_spans  = new ArrayPOD <ScanlineSpan>(1000);
 }
Beispiel #17
0
        //------------------------------------------------------------------------
        public void Prepare()
        {
            if (m_num > 2)
            {
                int i, k;
                int r;
                int s;
                double h, p, d, f, e;

                for (k = 0; k < m_num; k++)
                {
                    m_am[k] = 0.0;
                }

                int n1 = 3 * m_num;

                ArrayPOD<double> al = new ArrayPOD<double>(n1);

                for (k = 0; k < n1; k++)
                {
                    al[k] = 0.0;
                }

                r = m_num;
                s = m_num * 2;

                n1 = m_num - 1;
                d = m_am[m_xOffset + 1] - m_am[m_xOffset + 0];
                e = (m_am[m_yOffset + 1] - m_am[m_yOffset + 0]) / d;

                for (k = 1; k < n1; k++)
                {
                    h = d;
                    d = m_am[m_xOffset + k + 1] - m_am[m_xOffset + k];
                    f = e;
                    e = (m_am[m_yOffset + k + 1] - m_am[m_yOffset + k]) / d;
                    al[k] = d / (d + h);
                    al[r + k] = 1.0 - al[k];
                    al[s + k] = 6.0 * (e - f) / (h + d);
                }

                for (k = 1; k < n1; k++)
                {
                    p = 1.0 / (al[r + k] * al[k - 1] + 2.0);
                    al[k] *= -p;
                    al[s + k] = (al[s + k] - al[r + k] * al[s + k - 1]) * p;
                }

                m_am[n1] = 0.0;
                al[n1 - 1] = al[s + n1 - 1];
                m_am[n1 - 1] = al[n1 - 1];

                for (k = n1 - 2, i = 0; i < m_num - 2; i++, k--)
                {
                    al[k] = al[k] * al[k + 1] + al[s + k];
                    m_am[k] = al[k];
                }
            }
            m_last_idx = -1;
        }
Beispiel #18
0
 //--------------------------------------------------------------------
 public scanline_bin()
 {
     m_last_x     = (0x7FFFFFF0);
     m_spans      = new ArrayPOD <ScanlineSpan>(1000);
     m_span_index = 0;
 }
Beispiel #19
0
 public ArrayPOD(ArrayPOD <T> v)
 {
     m_array = (T[])v.m_array.Clone();
     m_size  = v.m_size;
 }
Beispiel #20
0
 //--------------------------------------------------------------------
 public BinaryScanline()
 {
     m_last_x     = (0x7FFFFFF0);
     m_spans      = new ArrayPOD <ScanlineSpan>(1000);
     m_span_index = 0;
 }
		//--------------------------------------------------------------------
		public scanline_bin()
		{
			m_last_x = (0x7FFFFFF0);
			m_spans = new ArrayPOD<ScanlineSpan>(1000);
			m_span_index = 0;
		}
 public span_allocator()
 {
     m_span = new ArrayPOD <Color>(255);
 }
Beispiel #23
0
 public span_allocator()
 {
     m_span = new ArrayPOD <RGBA_Bytes>(255);
 }
Beispiel #24
0
 public ScanlinePacked8()
 {
     m_last_x = 0x7FFFFFF0;
     m_covers = new ArrayPOD <byte>(1000);
     m_spans  = new ArrayPOD <ScanlineSpan>(1000);
 }
Beispiel #25
0
 //--------------------------------------------------------------------
 public BinaryScanline()
 {
     m_last_x=(0x7FFFFFF0);
     m_spans = new ArrayPOD<ScanlineSpan>(1000);
     m_span_index = 0;
 }
Beispiel #26
0
 public span_allocator()
 {
     m_span = new ArrayPOD<RGBA_Bytes>(255);
 }
Beispiel #27
0
		public polygon_ctrl_impl(int np, double point_radius)
			: base(new Vector2())
		{
			m_ellipse = new MatterHackers.Agg.VertexSource.Ellipse();
			m_polygon = new ArrayPOD<double>(np * 2);
			m_num_points = (np);
			m_node = (-1);
			m_edge = (-1);
			m_vs = new simple_polygon_vertex_source(m_polygon.Array, m_num_points, false);
			m_stroke = new Stroke(m_vs);
			m_point_radius = (point_radius);
			m_status = (0);
			m_dx = (0.0);
			m_dy = (0.0);
			m_in_polygon_check = (true);
			m_stroke.width(1.0);
		}
Beispiel #28
0
 public ImageFilterLookUpTable(IImageFilterFunction <T> filter, bool normalization)
 {
     m_weight_array = new ArrayPOD <short>(256);
     Calculate(filter, normalization);
 }