public static void ConvertPDFTOneImage() { MagickReadSettings settings = new MagickReadSettings(); // Settings the density to 300 dpi will create an image with a better quality settings.Density = new PointD(300, 300); using (MagickImageCollection images = new MagickImageCollection()) { // Add all the pages of the pdf file to the collection images.Read(SampleFiles.SnakewarePdf, settings); // Create new image that appends all the pages horizontally using (MagickImage horizontal = images.AppendHorizontally()) { // Save result as a png horizontal.Write(SampleFiles.OutputDirectory + "Snakeware.horizontal.png"); } // Create new image that appends all the pages horizontally using (MagickImage vertical = images.AppendVertically()) { // Save result as a png vertical.Write(SampleFiles.OutputDirectory + "Snakeware.vertical.png"); } } }
public void Test_Append() { int width = 70; int height = 46; using (MagickImageCollection collection = new MagickImageCollection(Files.RoseSparkleGIF)) { Assert.AreEqual(width, collection[0].Width); Assert.AreEqual(height, collection[0].Height); using (MagickImage image = collection.AppendHorizontally()) { Assert.AreEqual(width * 3, image.Width); Assert.AreEqual(height, image.Height); } using (MagickImage image = collection.AppendVertically()) { Assert.AreEqual(width, image.Width); Assert.AreEqual(height * 3, image.Height); } } }
public void Test_Append() { int width = 70; int height = 46; using (MagickImageCollection collection = new MagickImageCollection()) { ExceptionAssert.Throws<InvalidOperationException>(delegate () { collection.AppendHorizontally(); }); ExceptionAssert.Throws<InvalidOperationException>(delegate () { collection.AppendVertically(); }); collection.Read(Files.RoseSparkleGIF); Assert.AreEqual(width, collection[0].Width); Assert.AreEqual(height, collection[0].Height); using (MagickImage image = collection.AppendHorizontally()) { Assert.AreEqual(width * 3, image.Width); Assert.AreEqual(height, image.Height); } using (MagickImage image = collection.AppendVertically()) { Assert.AreEqual(width, image.Width); Assert.AreEqual(height * 3, image.Height); } } }
private static MagickImage ExecuteAppendVertically(MagickImageCollection collection) { return collection.AppendVertically(); }
private static MagickImage ExecuteAppendVertically(MagickImageCollection collection) { return(collection.AppendVertically()); }
public void Test_FlipFlop() { using (MagickImageCollection collection = new MagickImageCollection()) { collection.Add(new MagickImage(MagickColors.DodgerBlue, 10, 10)); collection.Add(new MagickImage(MagickColors.Firebrick, 10, 10)); using (MagickImage image = collection.AppendVertically()) { ColorAssert.AreEqual(MagickColors.DodgerBlue, image, 5, 0); ColorAssert.AreEqual(MagickColors.Firebrick, image, 5, 10); image.Flip(); ColorAssert.AreEqual(MagickColors.Firebrick, image, 5, 0); ColorAssert.AreEqual(MagickColors.DodgerBlue, image, 5, 10); } using (MagickImage image = collection.AppendHorizontally()) { ColorAssert.AreEqual(MagickColors.DodgerBlue, image, 0, 5); ColorAssert.AreEqual(MagickColors.Firebrick, image, 10, 5); image.Flop(); ColorAssert.AreEqual(MagickColors.Firebrick, image, 0, 5); ColorAssert.AreEqual(MagickColors.DodgerBlue, image, 10, 5); } } }
/// <summary> /// Combines the screenshots into one contiguous screenshot /// </summary> /// <param name="files">The files (images) to combine</param> /// <param name="e">For UX, an output progress message</param> public static void CombineScreenshot(FileSystemInfo[] files, WaitWindowEventArgs e) { string screenshotLocation = Path.Combine(Constants.CacheLocation, "temp.png"); using (MagickImageCollection images = new MagickImageCollection()) { // Add the first image var orderedFiles = files.OrderBy(f => f.CreationTime); foreach (FileSystemInfo file in orderedFiles) { MagickImage first = new MagickImage(file.FullName); e.Window.Message = "Obtaining Snapshots... Please Wait"; images.Add(first); } using (MagickImage result = images.AppendVertically()) { e.Window.Message = "Building Screenshot... Please Wait" + System.Environment.NewLine + "This can take a minute."; try { result.Write(screenshotLocation); } catch (MagickImageErrorException err) { Debug.WriteLine($"Error: {err}"); } } } }