public void PostProcess <TPixel>(TestImageProvider <TPixel> provider) where TPixel : unmanaged, IPixel <TPixel> { string imageFile = provider.SourceFileOrDescription; using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile)) using (var pp = new JpegImagePostProcessor(Configuration.Default, decoder)) using (var image = new Image <Rgba32>(decoder.ImageWidth, decoder.ImageHeight)) { pp.PostProcess(image.Frames.RootFrame); image.DebugSave(provider); ImagingTestCaseUtility testUtil = provider.Utility; testUtil.TestGroupName = nameof(JpegDecoderTests); testUtil.TestName = JpegDecoderTests.DecodeBaselineJpegOutputName; using (Image <TPixel> referenceImage = provider.GetReferenceOutputImage <TPixel>(appendPixelTypeToFileName: false)) { ImageSimilarityReport report = ImageComparer.Exact.CompareImagesOrFrames(referenceImage, image); this.Output.WriteLine($"*** {imageFile} ***"); this.Output.WriteLine($"Difference: {report.DifferencePercentageString}"); // ReSharper disable once PossibleInvalidOperationException Assert.True(report.TotalNormalizedDifference.Value < 0.005f); } } }
public Bitmap Load() { if (this.ImageWidth == 0 || this.ImageHeight == 0) { JpegThrowHelper.ThrowInvalidImageDimensions(this.ImageWidth, this.ImageHeight); } var buffer = new Buffer2D <Vector4>(MemoryGroup <Vector4> .Allocate(this.ImageWidth * this.ImageHeight, this.ImageWidth), this.ImageWidth, this.ImageHeight); using (var postProcessor = new JpegImagePostProcessor(this.RawData)) { postProcessor.PostProcess(buffer, new System.Threading.CancellationToken()); } var bitmap = new Bitmap(this.ImageWidth, this.ImageHeight); for (int y = 0; y < bitmap.Height; y++) { for (int x = 0; x < bitmap.Width; x++) { ref var p = ref buffer[x, y]; bitmap.PixelBufferView[x, y] = new Pixel() { A = p.W, B = p.Z, G = p.Y, R = p.X }; } }
private Image <TPixel> PostProcessIntoImage <TPixel>() where TPixel : struct, IPixel <TPixel> { using (var postProcessor = new JpegImagePostProcessor(this)) { var image = new Image <TPixel>(this.configuration, this.ImageWidth, this.ImageHeight, this.MetaData); postProcessor.PostProcess(image.Frames.RootFrame); return(image); } }
public void DoProcessorStep <TPixel>(TestImageProvider <TPixel> provider) where TPixel : unmanaged, IPixel <TPixel> { string imageFile = provider.SourceFileOrDescription; using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile)) using (var pp = new JpegImagePostProcessor(Configuration.Default, decoder)) using (var imageFrame = new ImageFrame <Rgba32>(Configuration.Default, decoder.ImageWidth, decoder.ImageHeight)) { pp.DoPostProcessorStep(imageFrame); JpegComponentPostProcessor[] cp = pp.ComponentProcessors; SaveBuffer(cp[0], provider); SaveBuffer(cp[1], provider); SaveBuffer(cp[2], provider); } }