Example #1
0
        public static void Simplify(this RawOutline rgnOutline, float tolerance = 0.5f, bool heighQualityEnable = false)
        {
            int j = rgnOutline._contours.Count;

            for (int i = 0; i < j; ++i)
            {
                RawContour   contour          = rgnOutline._contours[i];
                List <Point> simplifiedPoints = new List <Point>(contour._xyCoords.Count);
                PixelFarm.CpuBlit.VertexProcessing.SimplificationHelpers.Simplify(
                    contour._xyCoords,
                    (p1, p2) => p1 == p2,
                    p => p.X,
                    p => p.Y,
                    simplifiedPoints,
                    tolerance,
                    heighQualityEnable);
                //replace current raw contour with the new one
#if DEBUG
                System.Diagnostics.Debug.WriteLine("simplification before:" + contour._xyCoords.Count + ",after" + simplifiedPoints.Count);
#endif

                //create a new raw contour,
                //but you can replace internal data of the old contour too,
                RawContour newContour = new RawContour();
                newContour.IsOutside = contour.IsOutside;
                foreach (Point point in simplifiedPoints)
                {
                    newContour.AddPoint(point);
                }
                rgnOutline._contours[i] = newContour;
            }
        }
Example #2
0
 internal void AppendPoint(int x, int y) => _currentContour.AddPoint(x, y);