public static void Run() { //ExStart:CroppingByRectangleEMFImage // 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; Console.WriteLine("Running example CroppingByRectangleEMFImage"); // 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 + "CroppingByRectangleEMFImage_out.pdf", FileMode.Create)) { // Create an instance of Rectangle class with desired size and Perform the crop operation on object of Rectangle class and Set height and width and Save the results to disk image.Crop(new Rectangle(30, 50, 100, 150)); pdfOptions.VectorRasterizationOptions.PageWidth = image.Width; pdfOptions.VectorRasterizationOptions.PageHeight = image.Height; image.Save(outputStream, pdfOptions); } } Console.WriteLine("Finished example CroppingByRectangleEMFImage"); //ExEnd:CroppingByRectangleEMFImage }
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 }
public static void Run() { Console.WriteLine("Running example CropEMFFile"); // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); using (EmfImage image = Image.Load(dataDir + "test.emf") as EmfImage) { image.Crop(new Rectangle(10, 10, 100, 150)); Console.WriteLine(image.Width); Console.WriteLine(image.Height); image.Save(dataDir + "test.emf_crop.emf"); } Console.WriteLine("Finished example CropEMFFile"); }