Exemplo n.º 1
0
        public static void Run()
        {
            // ExStart:ExportRasterImageToSvg
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            string[] paths = new string[]
            {
                @"C:\test\butterfly.gif",
                @"C:\test\33715-cmyk.jpeg",
                @"C:\test\3.JPG",
                @"C:\test\test.j2k",
                @"C:\test\Rings.png",
                @"C:\test\3layers_maximized_comp.psd",
                @"C:\test\img4.TIF",
                @"C:\test\Lossy5.webp"
            };

            foreach (string path in paths)
            {
                string destPath = path + ".svg";

                using (Image image = Image.Load(path))
                {
                    SvgOptions svgOptions = new SvgOptions();
                    SvgRasterizationOptions svgRasterizationOptions = new SvgRasterizationOptions();
                    svgOptions.VectorRasterizationOptions            = svgRasterizationOptions;
                    svgOptions.VectorRasterizationOptions.PageWidth  = image.Width;
                    svgOptions.VectorRasterizationOptions.PageHeight = image.Height;

                    image.Save(destPath, svgOptions);
                }
            }
            // ExEnd:ExportRasterImageToSvg
        }
        public void WorkWithSvgOptions()
        {
            // ExStart:UseSvgOptions
            // ExFor: SvgOptions
            // ExFor: SvgOptions.#ctor
            // ExFor: SvgOptions.UseGradientBrush
            // ExFor: Timescale
            // ExSummary: Shows how to save project as SVG file.
            var         project = new Project(DataDir + "EstimatedMilestoneTasks.mpp");
            SaveOptions options = new SvgOptions
            {
                // set the <see cref="P:Aspose.Tasks.Saving.SaveOptions.PresentationFormat" /> in which the document will be saved
                PresentationFormat = PresentationFormat.GanttChart,

                // set a value indicating whether row height should be increased to fit its content
                FitContent = true,

                // set the minimal time period to render. The default value is <see cref="P:Aspose.Tasks.Saving.SaveOptions.Timescale">Days</see>
                Timescale = Timescale.ThirdsOfMonths,

                // determines whether to use gradient brush when rendering project layout
                // Currently using of gradient brush is not supported for rendering to SVG.
                // UseGradientBrush = true
            };

            project.Save(OutDir + "UseSvgOptions_out.svg", options);

            // ExEnd:UseSvgOptions
        }
 public static void Run()
 {
     // The path to the documents directory.
     string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
     
     // ExStart:UseSvgOptions
     // Read the input Project file
     Project project = new Project(dataDir + "CreateProject2.mpp");
     SaveOptions saveOptions = new SvgOptions();
     saveOptions.FitContent = true;
     saveOptions.Timescale = Timescale.ThirdsOfMonths;
     project.Save(dataDir + "UseSvgOptions_out.svg", saveOptions);
     // ExEnd:UseSvgOptions
 }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // ExStart:UseSvgOptions
            // Read the input Project file
            Project     project     = new Project(dataDir + "CreateProject2.mpp");
            SaveOptions saveOptions = new SvgOptions();

            saveOptions.FitContent = true;
            saveOptions.Timescale  = Timescale.ThirdsOfMonths;
            project.Save(dataDir + "UseSvgOptions_out.svg", saveOptions);
            // ExEnd:UseSvgOptions
        }
Exemplo n.º 5
0
        public static void Run()
        {
            //ExStart:ExportToSVG
            // The path to the documents directory.
            string MyDir = RunExamples.GetDataDir_DWGDrawings();

            using (Image image = Image.Load(MyDir + "sample.dwg"))
            {
                var options = new SvgOptions();
                options.ColorType    = Aspose.CAD.ImageOptions.SvgOptionsParameters.SvgColorMode.Grayscale;
                options.TextAsShapes = true;
                image.Save(MyDir + "sample.svg");
            }
            //ExEnd:ExportToSVG
        }
        public static void Run()
        {
            // ExStart:UsingXlsxOptions

            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_CreatingAndSaving();

            // Read the input Project file
            Project     project     = new Project(dataDir + "Project2.mpp");
            SaveOptions saveOptions = new SvgOptions();

            saveOptions.FitContent = true;
            saveOptions.Timescale  = Timescale.ThirdsOfMonths;
            project.Save(dataDir + "UseSvgOptions_out.svg", saveOptions);
            // ExEnd:UsingXlsxOptions
        }
        ///<Summary>
        /// ConvertCadToImages method to convert cad to images
        ///</Summary>
        public Response ConvertCadToImages(string fileName, string folderName, string outputType)
        {
            if (outputType.Equals("bmp") || outputType.Equals("jpg") || outputType.Equals("png") || outputType.Equals("gif") || outputType.Equals("svg"))
            {
                ImageOptionsBase imageOptionsBase = new BmpOptions();

                if (outputType.Equals("jpg"))
                {
                    imageOptionsBase = new JpegOptions();
                }
                else if (outputType.Equals("png"))
                {
                    imageOptionsBase = new PngOptions();
                }
                else if (outputType.Equals("gif"))
                {
                    imageOptionsBase = new GifOptions();
                }
                else if (outputType.Equals("svg"))
                {
                    imageOptionsBase = new SvgOptions();
                }
                return(ProcessTask(fileName, folderName, "." + outputType, false, false, delegate(string inFilePath, string outPath, string zipOutFolder)
                {
                    using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(inFilePath))
                    {
                        image.Save(outPath, imageOptionsBase);
                    }
                }));
            }


            return(new Response
            {
                FileName = null,
                Status = "Output type not found",
                StatusCode = 500
            });
        }
        ///<Summary>
        /// ConvertImageFormat method to convert image to different image formats
        ///</Summary>
        public Response ConvertImageFormat(string fileName, string folderName, string outputType)
        {
            if (outputType.Equals("gif") || outputType.Equals("bmp") || outputType.Equals("jpg") || outputType.Equals("png") ||
                outputType.Equals("psd") || outputType.Equals("emf") || outputType.Equals("svg") || outputType.Equals("wmf"))
            {
                ImageOptionsBase optionsBase = new BmpOptions();

                if (outputType.Equals("jpg"))
                {
                    optionsBase = new JpegOptions();
                }
                else if (outputType.Equals("png"))
                {
                    optionsBase = new PngOptions();
                }
                else if (outputType.Equals("gif"))
                {
                    optionsBase = new GifOptions();
                }
                else if (outputType.Equals("psd"))
                {
                    optionsBase = new PsdOptions();
                }
                else if (outputType.Equals("emf"))
                {
                    optionsBase = new EmfOptions();
                }
                else if (outputType.Equals("svg"))
                {
                    optionsBase = new SvgOptions();
                }
                else if (outputType.Equals("wmf"))
                {
                    optionsBase = new WmfOptions();
                }
                return(ProcessTask(fileName, folderName, "." + outputType, true, true, delegate(string inFilePath, string outPath, string zipOutFolder)
                {
                    string fileExtension = Path.GetExtension(inFilePath).ToLower();
                    if ((fileExtension == ".tif") || (fileExtension == ".tiff"))
                    {
                        string outfileName = Path.GetFileNameWithoutExtension(fileName) + "_{0}";
                        using (TiffImage multiImage = (TiffImage)Image.Load(inFilePath))
                        {
                            if (multiImage.Frames.Length > 1)
                            {
                                int frameCounter = 0;
                                // Iterate over the TiffFrames in TiffImage
                                foreach (TiffFrame tiffFrame in multiImage.Frames)
                                {
                                    multiImage.ActiveFrame = tiffFrame;
                                    // Load Pixels of TiffFrame into an array of Colors
                                    Color[] pixels = multiImage.LoadPixels(tiffFrame.Bounds);
                                    // Create an instance of JpegOptions

                                    // Set the Source of JpegOptions as FileCreateSource by specifying the location where output will be saved
                                    // Last boolean parameter denotes isTemporal
                                    outPath = zipOutFolder + "/" + outfileName;

                                    optionsBase.Source = new FileCreateSource(string.Format(outPath, frameCounter + 1) + "." + outputType, false);
                                    // Create a new RasterImage of Jpeg type
                                    using (var jpgImage = (RasterImage)Image.Create(optionsBase, tiffFrame.Width, tiffFrame.Height))
                                    {
                                        // Save the JpegImage with pixels from TiffFrame
                                        jpgImage.SavePixels(tiffFrame.Bounds, pixels);
                                        // Resize the Jpeg Image
                                        jpgImage.Resize(100, 100, ResizeType.NearestNeighbourResample);
                                        // Save the results on disk
                                        jpgImage.Save();
                                    }
                                    frameCounter++;
                                }
                            }
                            else
                            {
                                multiImage.Save(outPath, optionsBase);
                            }
                        }
                    }
                    else

                    {
                        using (Image image = Image.Load(inFilePath))
                        {
                            image.Save(outPath, optionsBase);
                        }
                    }
                }));
            }

            return(new Response
            {
                FileName = null,
                Status = "Output type not found",
                StatusCode = 500
            });
        }