public void BmpDecoder_CanDecode_MiscellaneousBitmaps <TPixel>(TestImageProvider <TPixel> provider, bool enforceDiscontiguousBuffers) where TPixel : struct, IPixel <TPixel> {
public void EncodeWorksWithoutSsse3Intrinsics(TestImageProvider <Rgba32> provider) {
public void DegenerateMemoryRequest_ShouldTranslateTo_ImageFormatException <TPixel>(TestImageProvider <TPixel> provider) where TPixel : unmanaged, IPixel <TPixel> { provider.LimitAllocatorBufferCapacity().InBytesSqrt(10); InvalidImageContentException ex = Assert.Throws <InvalidImageContentException>(() => provider.GetImage(JpegDecoder)); this.Output.WriteLine(ex.Message); Assert.IsType <InvalidMemoryOperationException>(ex.InnerException); }
public void EncodeBaseline_WorksWithDifferentSizes <TPixel>(TestImageProvider <TPixel> provider, JpegSubsample subsample, int quality) where TPixel : unmanaged, IPixel <TPixel> => TestJpegEncoderCore(provider, subsample, quality);
public void ApplyBrightnessFilter <TPixel>(TestImageProvider <TPixel> provider, float value) where TPixel : struct, IPixel <TPixel> { provider.RunValidatingProcessorTest(ctx => ctx.Brightness(value), value); }
public void Encode_PreservesMetadata <TPixel>(TestImageProvider <TPixel> provider) where TPixel : unmanaged, IPixel <TPixel> { // Load Tiff image using Image <TPixel> image = provider.GetImage(new TiffDecoder() { IgnoreMetadata = false }); ImageMetadata inputMetaData = image.Metadata; ImageFrame <TPixel> rootFrameInput = image.Frames.RootFrame; TiffFrameMetadata frameMetaInput = rootFrameInput.Metadata.GetTiffMetadata(); byte[] xmpProfileInput = rootFrameInput.Metadata.XmpProfile; ExifProfile exifProfileInput = rootFrameInput.Metadata.ExifProfile; Assert.Equal(TiffCompression.Lzw, frameMetaInput.Compression); Assert.Equal(TiffBitsPerPixel.Bit4, frameMetaInput.BitsPerPixel); // Save to Tiff var tiffEncoder = new TiffEncoder() { PhotometricInterpretation = TiffPhotometricInterpretation.Rgb }; using var ms = new MemoryStream(); image.Save(ms, tiffEncoder); // Assert ms.Position = 0; using var encodedImage = Image.Load <Rgba32>(ms); ImageMetadata encodedImageMetaData = encodedImage.Metadata; ImageFrame <Rgba32> rootFrameEncodedImage = encodedImage.Frames.RootFrame; TiffFrameMetadata tiffMetaDataEncodedRootFrame = rootFrameEncodedImage.Metadata.GetTiffMetadata(); ExifProfile encodedImageExifProfile = rootFrameEncodedImage.Metadata.ExifProfile; byte[] encodedImageXmpProfile = rootFrameEncodedImage.Metadata.XmpProfile; Assert.Equal(TiffBitsPerPixel.Bit4, tiffMetaDataEncodedRootFrame.BitsPerPixel); Assert.Equal(TiffCompression.Lzw, tiffMetaDataEncodedRootFrame.Compression); Assert.Equal(inputMetaData.HorizontalResolution, encodedImageMetaData.HorizontalResolution); Assert.Equal(inputMetaData.VerticalResolution, encodedImageMetaData.VerticalResolution); Assert.Equal(inputMetaData.ResolutionUnits, encodedImageMetaData.ResolutionUnits); Assert.Equal(rootFrameInput.Width, rootFrameEncodedImage.Width); Assert.Equal(rootFrameInput.Height, rootFrameEncodedImage.Height); PixelResolutionUnit resolutionUnitInput = UnitConverter.ExifProfileToResolutionUnit(exifProfileInput); PixelResolutionUnit resolutionUnitEncoded = UnitConverter.ExifProfileToResolutionUnit(encodedImageExifProfile); Assert.Equal(resolutionUnitInput, resolutionUnitEncoded); Assert.Equal(exifProfileInput.GetValue(ExifTag.XResolution).Value.ToDouble(), encodedImageExifProfile.GetValue(ExifTag.XResolution).Value.ToDouble()); Assert.Equal(exifProfileInput.GetValue(ExifTag.YResolution).Value.ToDouble(), encodedImageExifProfile.GetValue(ExifTag.YResolution).Value.ToDouble()); Assert.Equal(xmpProfileInput, encodedImageXmpProfile); Assert.Equal("IrfanView", exifProfileInput.GetValue(ExifTag.Software).Value); Assert.Equal("This is Название", exifProfileInput.GetValue(ExifTag.ImageDescription).Value); Assert.Equal("This is Изготовитель камеры", exifProfileInput.GetValue(ExifTag.Make).Value); Assert.Equal("This is Авторские права", exifProfileInput.GetValue(ExifTag.Copyright).Value); Assert.Equal(exifProfileInput.GetValue(ExifTag.ImageDescription).Value, encodedImageExifProfile.GetValue(ExifTag.ImageDescription).Value); Assert.Equal(exifProfileInput.GetValue(ExifTag.Make).Value, encodedImageExifProfile.GetValue(ExifTag.Make).Value); Assert.Equal(exifProfileInput.GetValue(ExifTag.Copyright).Value, encodedImageExifProfile.GetValue(ExifTag.Copyright).Value); // Note that the encoded profile has PlanarConfiguration explicitly set, which is missing in the original image profile. Assert.Equal((ushort)TiffPlanarConfiguration.Chunky, encodedImageExifProfile.GetValue(ExifTag.PlanarConfiguration)?.Value); Assert.Equal(exifProfileInput.Values.Count + 1, encodedImageExifProfile.Values.Count); }
public void ApplyLomographFilter <TPixel>(TestImageProvider <TPixel> provider) where TPixel : struct, IPixel <TPixel> { provider.RunValidatingProcessorTest(x => x.Lomograph()); }
public void DecodeBaselineJpeg <TPixel>(TestImageProvider <TPixel> provider) where TPixel : struct, IPixel <TPixel> {
public void GetGlobalInstance <TPixel>(TestImageProvider <TPixel> dummy) where TPixel : struct, IPixel <TPixel> { Assert.NotNull(PixelOperations <TPixel> .Instance); }
public void DecodeBaselineJpeg_CriticalEOF_ShouldThrow_Orig <TPixel>(TestImageProvider <TPixel> provider) where TPixel : struct, IPixel <TPixel> { // TODO: We need a public ImageDecoderException class in ImageSharp! Assert.ThrowsAny <Exception>(() => provider.GetImage(OrigJpegDecoder)); }
public void CompareJpegDecoders_Progressive <TPixel>(TestImageProvider <TPixel> provider) where TPixel : struct, IPixel <TPixel> { this.CompareJpegDecodersImpl(provider, DecodeProgressiveJpegOutputName); }
public void EntropyCrop <TPixel>(TestImageProvider <TPixel> provider, float value) where TPixel : unmanaged, IPixel <TPixel> { provider.RunValidatingProcessorTest(x => x.EntropyCrop(value), value, appendPixelTypeToFileName: false); }
public void GetGlobalInstance <TColor>(TestImageProvider <TColor> dummy) where TColor : struct, IPixel <TColor> { Assert.NotNull(BulkPixelOperations <TColor> .Instance); }
public void Resize_IsNotBoundToSinglePixelType <TPixel>(TestImageProvider <TPixel> provider) where TPixel : struct, IPixel <TPixel> { provider.RunValidatingProcessorTest(x => x.Resize(x.GetCurrentSize() / 2), comparer: ValidatorComparer); }
public void GifDecoder_CanDecode_WithLimitedAllocatorBufferCapacity( TestImageProvider <Rgba32> provider) {
public void ApplyColorBlindnessFilter <TPixel>(TestImageProvider <TPixel> provider, ColorBlindnessMode colorBlindness) where TPixel : unmanaged, IPixel <TPixel> => provider.RunValidatingProcessorTest(x => x.ColorBlindness(colorBlindness), colorBlindness.ToString(), this.imageComparer);
public void BaselineTags <TPixel>(TestImageProvider <TPixel> provider) where TPixel : unmanaged, IPixel <TPixel> { using (Image <TPixel> image = provider.GetImage(TiffDecoder)) { ImageFrame <TPixel> rootFrame = image.Frames.RootFrame; Assert.Equal(32, rootFrame.Width); Assert.Equal(32, rootFrame.Height); Assert.NotNull(rootFrame.Metadata.XmpProfile); Assert.Equal(2599, rootFrame.Metadata.XmpProfile.Length); ExifProfile exifProfile = rootFrame.Metadata.ExifProfile; TiffFrameMetadata tiffFrameMetadata = rootFrame.Metadata.GetTiffMetadata(); Assert.NotNull(exifProfile); // The original exifProfile has 30 values, but 4 of those values will be stored in the TiffFrameMetaData // and removed from the profile on decode. Assert.Equal(26, exifProfile.Values.Count); Assert.Equal(TiffBitsPerPixel.Bit4, tiffFrameMetadata.BitsPerPixel); Assert.Equal(TiffCompression.Lzw, tiffFrameMetadata.Compression); Assert.Equal("This is Название", exifProfile.GetValue(ExifTag.ImageDescription).Value); Assert.Equal("This is Изготовитель камеры", exifProfile.GetValue(ExifTag.Make).Value); Assert.Equal("This is Модель камеры", exifProfile.GetValue(ExifTag.Model).Value); Assert.Equal("IrfanView", exifProfile.GetValue(ExifTag.Software).Value); Assert.Null(exifProfile.GetValue(ExifTag.DateTime)?.Value); Assert.Equal("This is author1;Author2", exifProfile.GetValue(ExifTag.Artist).Value); Assert.Null(exifProfile.GetValue(ExifTag.HostComputer)?.Value); Assert.Equal("This is Авторские права", exifProfile.GetValue(ExifTag.Copyright).Value); Assert.Equal(4, exifProfile.GetValue(ExifTag.Rating).Value); Assert.Equal(75, exifProfile.GetValue(ExifTag.RatingPercent).Value); var expectedResolution = new Rational(10000, 1000, simplify: false); Assert.Equal(expectedResolution, exifProfile.GetValue(ExifTag.XResolution).Value); Assert.Equal(expectedResolution, exifProfile.GetValue(ExifTag.YResolution).Value); Assert.Equal(new Number[] { 8u }, exifProfile.GetValue(ExifTag.StripOffsets)?.Value, new NumberComparer()); Assert.Equal(new Number[] { 297u }, exifProfile.GetValue(ExifTag.StripByteCounts)?.Value, new NumberComparer()); Assert.Null(exifProfile.GetValue(ExifTag.ExtraSamples)?.Value); Assert.Equal(32u, exifProfile.GetValue(ExifTag.RowsPerStrip).Value); Assert.Null(exifProfile.GetValue(ExifTag.SampleFormat)); Assert.Equal(TiffPredictor.None, tiffFrameMetadata.Predictor); Assert.Equal(PixelResolutionUnit.PixelsPerInch, UnitConverter.ExifProfileToResolutionUnit(exifProfile)); ushort[] colorMap = exifProfile.GetValue(ExifTag.ColorMap)?.Value; Assert.NotNull(colorMap); Assert.Equal(48, colorMap.Length); Assert.Equal(10537, colorMap[0]); Assert.Equal(14392, colorMap[1]); Assert.Equal(58596, colorMap[46]); Assert.Equal(3855, colorMap[47]); Assert.Equal(TiffPhotometricInterpretation.PaletteColor, tiffFrameMetadata.PhotometricInterpretation); Assert.Equal(1u, exifProfile.GetValue(ExifTag.SamplesPerPixel).Value); ImageMetadata imageMetaData = image.Metadata; Assert.NotNull(imageMetaData); Assert.Equal(PixelResolutionUnit.PixelsPerInch, imageMetaData.ResolutionUnits); Assert.Equal(10, imageMetaData.HorizontalResolution); Assert.Equal(10, imageMetaData.VerticalResolution); TiffMetadata tiffMetaData = image.Metadata.GetTiffMetadata(); Assert.NotNull(tiffMetaData); Assert.Equal(ByteOrder.LittleEndian, tiffMetaData.ByteOrder); } }
public void ApplyBlackWhiteFilter <TPixel>(TestImageProvider <TPixel> provider) where TPixel : struct, IPixel <TPixel> { provider.RunValidatingProcessorTest(ctx => ctx.BlackWhite()); }
public void BmpDecoder_CanDecode_MiscellaneousBitmaps_WithLimitedAllocatorBufferCapacity( TestImageProvider <Rgba32> provider) {
public void ApplySaturationFilter <TPixel>(TestImageProvider <TPixel> provider, float value) where TPixel : unmanaged, IPixel <TPixel> { provider.RunValidatingProcessorTest(x => x.Saturate(value), value); }
public void GetGlobalInstance <T>(TestImageProvider <T> _) where T : unmanaged, IPixel <T> => Assert.NotNull(PixelOperations <T> .Instance);
private string GetDifferenceInPercentageString <TPixel>(Image <TPixel> image, TestImageProvider <TPixel> provider) where TPixel : struct, IPixel <TPixel> { var reportingComparer = ImageComparer.Tolerant(0, 0); ImageSimilarityReport report = image.GetReferenceOutputSimilarityReports( provider, reportingComparer, appendPixelTypeToFileName: false ).SingleOrDefault(); if (report?.TotalNormalizedDifference != null) { return(report.DifferencePercentageString); } return("0%"); }
public void EncodeBaseline_IsNotBoundToSinglePixelType <TPixel>(TestImageProvider <TPixel> provider, JpegSubsample subsample, int quality) where TPixel : unmanaged, IPixel <TPixel> => TestJpegEncoderCore(provider, subsample, quality);
public void TgaDecoder_CanDecode_RunLengthEncoded_Gray_WithTopRightOrigin_16Bit <TPixel>(TestImageProvider <TPixel> provider) where TPixel : unmanaged, IPixel <TPixel> { using (Image <TPixel> image = provider.GetImage(TgaDecoder)) { image.DebugSave(provider); // Using here the reference output instead of the the reference decoder, // because the reference decoder output seems not to be correct for 16bit gray images. image.CompareToReferenceOutput(ImageComparer.Exact, provider); } }
public void ApplyGrayscaleFilter <TPixel>(TestImageProvider <TPixel> provider, GrayscaleMode value) where TPixel : unmanaged, IPixel <TPixel> { provider.RunValidatingProcessorTest(x => x.Grayscale(value), value); }
public void TgaDecoder_CanDecode_WithPalette_WithTopRightOrigin_32Bit <TPixel>(TestImageProvider <TPixel> provider) where TPixel : unmanaged, IPixel <TPixel> { using (Image <TPixel> image = provider.GetImage(TgaDecoder)) { image.DebugSave(provider); TgaTestUtils.CompareWithReferenceDecoder(provider, image); } }
public void ApplyBlackWhiteFilter <TPixel>(TestImageProvider <TPixel> provider) where TPixel : unmanaged, IPixel <TPixel> { provider.RunValidatingProcessorTest(ctx => ctx.BlackWhite(), comparer: ImageComparer.TolerantPercentage(0.002f)); }
public void TgaDecoder_CanDecode_RunLengthEncoded_Gray_WithBottomLeftOrigin_8Bit <TPixel>(TestImageProvider <TPixel> provider) where TPixel : unmanaged, IPixel <TPixel> { using (Image <TPixel> image = provider.GetImage(TgaDecoder)) { image.DebugSave(provider); TgaTestUtils.CompareWithReferenceDecoder(provider, image); } }
public void ApplyInvertFilter <TPixel>(TestImageProvider <TPixel> provider) where TPixel : unmanaged, IPixel <TPixel> { provider.RunValidatingProcessorTest(x => x.Invert()); }
public void Rotate_WithRotateTypeEnum <TPixel>(TestImageProvider <TPixel> provider, RotateMode value) where TPixel : unmanaged, IPixel <TPixel> { provider.RunValidatingProcessorTest(ctx => ctx.Rotate(value), value, appendPixelTypeToFileName: false); }