/// <summary> /// Initializes a new instance of the Rasterizer class. /// </summary> public Rasterizer() { m_filling_rule = FillingRule.FillNonZero; m_outline = new Outline(); m_scanline = new Scanline(); m_gamma = new byte[256]; Array.Copy(defaultGamma, m_gamma, m_gamma.Length); }
/// <summary> /// Renders the specified scanline in the specified color into the /// rendering buffer. /// </summary> /// <param name="scanline">The scanline to render.</param> /// <param name="color">The color to render the scanline.</param> public void Render(Scanline scanline, Color color) { if (scanline.Y < 0 || scanline.Y >= m_rbuf.Height) { return; } int base_x = scanline.BaseX; int y = scanline.Y; RowIterator row = m_rbuf.Row(y); Scanline.Iterator span = new Scanline.Iterator(scanline); for (int num_spans = scanline.SpanCount; num_spans > 0; num_spans--) { int x = span.Next() + base_x; CoverageIterator covers = span.Covers(); int num_pix = span.PixelCount(); if (x < 0) { num_pix += x; if (num_pix <= 0) { continue; } covers -= x; x = 0; } if (x + num_pix >= m_rbuf.Width) { num_pix = m_rbuf.Width - x; if (num_pix <= 0) { continue; } } m_span.Render(row, x, num_pix, covers, color); } }
/// <summary> /// Initializes a new instance of the Iterator class using the /// specified scanline. /// </summary> /// <param name="scanline">The scanline.</param> public Iterator(Scanline scanline) { m_covers = new CoverageIterator(scanline.m_covers); m_counts = scanline.m_counts; m_start_indeces = scanline.m_start_indeces; }