Пример #1
0
        public string ConvertBitmap(Bitmap bitmap)
        {
            bool[,] Matrix;
            ArrayList ListOfCurveArray = new ArrayList();

            Matrix = Potrace.BitMapToBinary(bitmap, 1);
            Potrace.potrace_trace(Matrix, ListOfCurveArray);
            string s = Potrace.Export2StringSVG(ListOfCurveArray, bitmap.Width, bitmap.Height);

            s = s.Replace("\n", " ").Replace("|", " ").Replace("  ", " ");
            return(s);
        }
        private static string GetHolePath(Potrace.Curve[] Curves)
        {
            StringBuilder path = new StringBuilder();

            for (int i = Curves.Length - 1; i >= 0; i--)
            {
                Potrace.Curve Curve = Curves[i];

                if (i == Curves.Length - 1)
                {
                    path.AppendLine("M" + Curve.B.x.ToString("0.0", enUsCulture) + " " + Curve.B.y.ToString("0.0", enUsCulture));
                }

                if (Curve.Kind == Potrace.CurveKind.Bezier)
                {

                    path.Append("C" + Curve.ControlPointB.x.ToString("0.0", enUsCulture) + " " + Curve.ControlPointB.y.ToString("0.0", enUsCulture) + " " +
                                  Curve.ControlPointA.x.ToString("0.0", enUsCulture) + " " + Curve.ControlPointA.y.ToString("0.0", enUsCulture) + " " +
                                  Curve.A.x.ToString("0.0", enUsCulture) + " " + Curve.A.y.ToString("0.0", enUsCulture));

                }
                if (Curve.Kind == Potrace.CurveKind.Line)
                {
                    path.Append("L" + Curve.B.x.ToString("0.0", enUsCulture) + " " + Curve.B.y.ToString("0.0", enUsCulture));

                }
                if (i == 0)
                {
                    path.Append("Z");
                }
                else
                {
                    path.AppendLine("");
                }

            }

            return path.ToString();
        }