public void EncodeJpeg(int executionCount, int quality, JpegSubsample subsample) { string[] testFiles = TestImages.Bmp.All .Concat(new[] { TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk }) .ToArray(); Image <Rgba32>[] testImages = testFiles.Select( tf => TestImageProvider <Rgba32> .File(tf, pixelTypeOverride: PixelTypes.StandardImageClass).GetImage()) .ToArray(); using (MemoryStream ms = new MemoryStream()) { this.Measure(executionCount, () => { foreach (Image <Rgba32> img in testImages) { JpegEncoder encoder = new JpegEncoder(); JpegEncoderOptions options = new JpegEncoderOptions { Quality = quality, Subsample = subsample }; img.Save(ms, encoder, options); ms.Seek(0, SeekOrigin.Begin); } }, // ReSharper disable once ExplicitCallerInfoArgument $@"Encode {testFiles.Length} images" ); } }
public void LoadsImageWithoutThrowingCrcException() { var image1Provider = TestImageProvider <Rgba32> .File(TestImages.Png.VersioningImage1); using (Image <Rgba32> img = image1Provider.GetImage()) { Assert.Equal(166036, img.Pixels.Length); } }
public void TestsThatVersioningImagesAreEqual() { var image1Provider = TestImageProvider <Rgba32> .File(TestImages.Png.VersioningImage1); var image2Provider = TestImageProvider <Rgba32> .File(TestImages.Png.VersioningImage2); using (Image <Rgba32> img1 = image1Provider.GetImage()) using (Image <Rgba32> img2 = image2Provider.GetImage()) { bool imagesEqual = AreImagesEqual(img1, img2); Assert.True(imagesEqual); } }