private SampleImage CreateSampleImage(string path) { if (this.IsFile(path, "hong-kong-large.jpg")) { return(this.LargeLandscape = new SampleImage(path, 1000, 665)); } if (this.IsFile(path, "derweze-large-wide.jpg")) { return(this.LargePanorama = new SampleImage(path, 2500, 671)); } if (this.IsFile(path, "umbrella-large-portrait.jpg")) { return(this.LargePortrait = new SampleImage(path, 665, 1000)); } if (this.IsFile(path, "colored-edges.png")) { return(this.ColoredEdges = new SampleImage(path, 1000, 1000)); } if (this.IsFile(path, "pc260001.tif")) { return(this.Tiff = new SampleImage(path, 640, 480)); } if (this.IsFile(path, "trees-no-profile.jpg")) { return(this.NoProfile = new SampleImage(path, 640, 480)); } if (this.IsFile(path, "trees-quality-50.jpg")) { return(this.LowQuality = new SampleImage(path, 640, 480)); } if (this.IsFile(path, "trees-quality-95.jpg")) { return(this.HighQuality = new SampleImage(path, 640, 480)); } if (this.IsFile(path, "phone-portrait-photo.jpeg")) { return(this.ExifRotated = new SampleImage(path, 2448, 3264)); } return(new SampleImage(path, 0, 0)); }
private void PerformResizeTest( SampleImage sampleImage, int desiredWidth, int desiredHeight, ResizeBehaviour resizeBehaviour, ProcessingBehaviour processingBehaviour, params Action <Bitmap>[] asserts) { using (var inputStream = sampleImage.Open()) using (var input = new MagickImage(inputStream)) using (var outputStream = new MemoryStream()) { this.target.Resize(input, outputStream, desiredWidth, desiredHeight, resizeBehaviour, processingBehaviour); ////SaveImage(input, desiredWidth, desiredHeight, resizeBehaviour); outputStream.Seek(0, SeekOrigin.Begin); var outputImage = new Bitmap(outputStream); foreach (var assert in asserts) { assert(outputImage); } if (resizeBehaviour == ResizeBehaviour.MaintainAspectRatio) { Assert.IsTrue( this.AreClose( sampleImage.Width / (double)sampleImage.Height, outputImage.Width / (double)outputImage.Height)); } else { Assert.IsTrue( this.AreClose(desiredWidth / (double)desiredHeight, outputImage.Width / (double)outputImage.Height)); } } }