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

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

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

            // Create an instance of Rasterization options
            EmfRasterizationOptions emfRasterizationOptions = new EmfRasterizationOptions();
            emfRasterizationOptions.BackgroundColor = Color.WhiteSmoke;

            // Create an instance of PNG options
            PdfOptions pdfOptions = new PdfOptions();
            pdfOptions.VectorRasterizationOptions = emfRasterizationOptions;

            // Load an existing image into an instance of EMF class
            using (EmfImage image = (EmfImage)Image.Load(dataDir + "Picture1.emf"))
            {
                using (FileStream outputStream = new FileStream(dataDir + "CroppingEMFImage_out.pdf", FileMode.Create))
                {
                    // Based on the shift values, apply the cropping on image and Crop method will shift the image bounds toward the center of image
                    image.Crop(30, 40, 50, 60);

                    // Set height and width and  Save the results to disk
                    pdfOptions.VectorRasterizationOptions.PageWidth = image.Width;
                    pdfOptions.VectorRasterizationOptions.PageHeight = image.Height;
                    image.Save(outputStream, pdfOptions);
                }
            }
            // ExEnd:CroppingEMFImage
        }      
    }
CroppingEMFImage