Aspose.Imaging.Examples.CSharp.ModifyingAndConvertingImages.ConvertWMFToPNG.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // ExStart:ConvertWMFToPNG
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Load an existing WMF image
            using (Image image = Image.Load(dataDir + "input.wmf"))
            {
                // Calculate new Webp image height
                double k = (image.Width * 1.00) / image.Height;

                // Create an instance of EmfRasterizationOptions class and set different properties
                EmfRasterizationOptions emfRasterization = new EmfRasterizationOptions
                {
                    BackgroundColor = Color.WhiteSmoke,
                    PageWidth = 400,
                    PageHeight = (int)Math.Round(400 / k),
                    BorderX = 5,
                    BorderY = 10
                };

                // Create an instance of PngOptions class and provide rasterization option
                ImageOptionsBase imageOptions = new PngOptions();
                imageOptions.VectorRasterizationOptions = emfRasterization;

                // Call the save method, provide output path and PngOptions to convert the WMF file to PNG and save the output
                image.Save(dataDir + "ConvertWMFToPNG_out.png", imageOptions);
            }
            // ExEnd:ConvertWMFToPNG
        }
    }
ConvertWMFToPNG