Пример #1
0
        public void Save(string filename, bool useGlobalExtension,
                         Image image, Drawable drawable)
        {
            _horizontalSlices.Sort();
            _verticalSlices.Sort();

            string name = System.IO.Path.GetFileNameWithoutExtension(image.Name);
            var    fs   = new FileStream(filename, FileMode.Create, FileAccess.Write);

            var w = new StreamWriter(fs);

            w.WriteLine("<html>");
            w.WriteLine("<head>");
            w.WriteLine("<meta name=\"Author\" content=\"{0}\">",
                        Environment.UserName);
            w.WriteLine("<meta name=\"Generator\" content=\"GIMP {0}\">",
                        Gimp.Version);
            w.WriteLine("<title></title>");
            WriteJavaScript(w);
            w.WriteLine("</head>");
            w.WriteLine("");

            w.Write("<body");

            var preload = JavaScriptProperty.Preload;
            int count   = preload.Length;

            if (count > 0)
            {
                w.Write(" onLoad=\"preloadImages('{0}'",
                        System.IO.Path.GetFileName(preload[0]));
                for (int i = 1; i < count; i++)
                {
                    w.Write(", '{0}'", System.IO.Path.GetFileName(preload[i]));
                }
                w.Write(")\"");
            }
            w.WriteLine(">");

            w.WriteLine("");
            w.WriteLine("<!-- Begin Table -->");
            w.WriteLine("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"{0}\">",
                        drawable.Width);

            _rectangles.WriteHTML(w, name, useGlobalExtension);
            WriteBlankLine(w);

            w.WriteLine("</table>");
            w.WriteLine("<!-- End Table -->");
            w.WriteLine("");
            w.WriteLine("</body>");
            w.WriteLine("</html>");
            w.Close();

            string path = System.IO.Path.GetDirectoryName(filename);

            _rectangles.WriteSlices(image, path, name, useGlobalExtension);
        }