diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs index 23ead7d663..a4fd1aa73c 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs @@ -220,7 +220,6 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif if (this.TryReadSpan(buffer)) { object value = this.ConvertValue(tag.Exif, tag.DataType, buffer, tag.NumberOfComponents > 1 || tag.Exif.IsArray); - this.Add(values, tag.Exif, value); } } @@ -450,7 +449,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif // Likewise, tags that point to other IFDs, like e.g. the SubIFDs tag, are now allowed to have the datatype TIFF_IFD8 in BigTIFF. // Again, the old datatypes TIFF_IFD, and the hardly recommendable TIFF_LONG, are still valid, too. // https://www.awaresystems.be/imaging/tiff/bigtiff.html - ExifValue exifValue = null; + ExifValue exifValue; switch (tag) { case ExifTagValue.StripOffsets: diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifValues.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifValues.cs index a92d062a47..fa5cf9b2fa 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifValues.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifValues.cs @@ -16,33 +16,33 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif switch (dataType) { case ExifDataType.Byte: - return isArray ? (ExifValue)new ExifByteArray(tag, dataType) : new ExifByte(tag, dataType); + return isArray ? new ExifByteArray(tag, dataType) : new ExifByte(tag, dataType); case ExifDataType.DoubleFloat: - return isArray ? (ExifValue)new ExifDoubleArray(tag) : new ExifDouble(tag); + return isArray ? new ExifDoubleArray(tag) : new ExifDouble(tag); case ExifDataType.SingleFloat: - return isArray ? (ExifValue)new ExifFloatArray(tag) : new ExifFloat(tag); + return isArray ? new ExifFloatArray(tag) : new ExifFloat(tag); case ExifDataType.Long: - return isArray ? (ExifValue)new ExifLongArray(tag) : new ExifLong(tag); + return isArray ? new ExifLongArray(tag) : new ExifLong(tag); case ExifDataType.Long8: - return isArray ? (ExifValue)new ExifLong8Array(tag) : new ExifLong8(tag); + return isArray ? new ExifLong8Array(tag) : new ExifLong8(tag); case ExifDataType.Rational: - return isArray ? (ExifValue)new ExifRationalArray(tag) : new ExifRational(tag); + return isArray ? new ExifRationalArray(tag) : new ExifRational(tag); case ExifDataType.Short: - return isArray ? (ExifValue)new ExifShortArray(tag) : new ExifShort(tag); + return isArray ? new ExifShortArray(tag) : new ExifShort(tag); case ExifDataType.SignedByte: - return isArray ? (ExifValue)new ExifSignedByteArray(tag) : new ExifSignedByte(tag); + return isArray ? new ExifSignedByteArray(tag) : new ExifSignedByte(tag); case ExifDataType.SignedLong: - return isArray ? (ExifValue)new ExifSignedLongArray(tag) : new ExifSignedLong(tag); + return isArray ? new ExifSignedLongArray(tag) : new ExifSignedLong(tag); case ExifDataType.SignedLong8: - return isArray ? (ExifValue)new ExifSignedLong8Array(tag) : new ExifSignedLong8(tag); + return isArray ? new ExifSignedLong8Array(tag) : new ExifSignedLong8(tag); case ExifDataType.SignedRational: - return isArray ? (ExifValue)new ExifSignedRationalArray(tag) : new ExifSignedRational(tag); + return isArray ? new ExifSignedRationalArray(tag) : new ExifSignedRational(tag); case ExifDataType.SignedShort: - return isArray ? (ExifValue)new ExifSignedShortArray(tag) : new ExifSignedShort(tag); + return isArray ? new ExifSignedShortArray(tag) : new ExifSignedShort(tag); case ExifDataType.Ascii: return new ExifString(tag); case ExifDataType.Undefined: - return isArray ? (ExifValue)new ExifByteArray(tag, dataType) : new ExifByte(tag, dataType); + return isArray ? new ExifByteArray(tag, dataType) : new ExifByte(tag, dataType); default: return null; } diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs index 4e3a08c393..93aeb75f48 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs @@ -88,7 +88,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms this.transposedFirstPassBuffer = configuration.MemoryAllocator.Allocate2D( this.workerHeight, destWidth, - AllocationOptions.Clean); + preferContiguosImageBuffers: true, + options: AllocationOptions.Clean); this.tempRowBuffer = configuration.MemoryAllocator.Allocate(this.sourceRectangle.Width); this.tempColumnBuffer = configuration.MemoryAllocator.Allocate(destWidth); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index 022bb224c4..6e275b824e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -669,5 +669,17 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms Assert.Equal(height, image.Height); } } + + [Theory] + [WithBasicTestPatternImages(20, 20, PixelTypes.Rgba32)] + public void Issue1625_LimitedAllocator(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + provider.LimitAllocatorBufferCapacity().InBytes(1000); + provider.RunValidatingProcessorTest( + x => x.Resize(30, 30), + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); + } } } diff --git a/tests/Images/External/ReferenceOutput/ResizeTests/Issue1625_LimitedAllocator.png b/tests/Images/External/ReferenceOutput/ResizeTests/Issue1625_LimitedAllocator.png new file mode 100644 index 0000000000..01e9cf38f3 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/ResizeTests/Issue1625_LimitedAllocator.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bedaced9c302ff735319f189d867b6a722ed4eade63152b67cf07881f8b3964d +size 289