Aspose.Imaging.Examples.CSharp.ModifyingAndConvertingImages.ResizeWMFFile.Run C# (CSharp) Метод

Run() публичный статический Метод

public static Run ( ) : void
Результат void
        public static void Run()
        {
            // ExStart:ResizeWMFFile
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Load an existing WMF image
            using (Image image = Image.Load(dataDir + "input.wmf"))
            {
                // Call the resize method of Image class and width,height values and Calculate new PNG image height
                image.Resize(100, 100);
                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 = 100,
                    PageHeight = (int)Math.Round(100 / 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 + "CreateEMFMetaFileImage_out.png", imageOptions);
                // ExStart:ResizeWMFFile
            }
        }
    }
ResizeWMFFile