Browse Source

Merge branch 'exif-encoded-strings' of github.com:IldarKhayrutdinov/ImageSharp into exif-encoded-strings

pull/1935/head
Ildar Khayrutdinov 4 years ago
parent
commit
d3c635ffd5
  1. 3
      src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs
  2. 26
      src/ImageSharp/Metadata/Profiles/Exif/Values/ExifValues.cs
  3. 3
      src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs
  4. 12
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs
  5. 3
      tests/Images/External/ReferenceOutput/ResizeTests/Issue1625_LimitedAllocator.png

3
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:

26
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;
}

3
src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs

@ -88,7 +88,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
this.transposedFirstPassBuffer = configuration.MemoryAllocator.Allocate2D<Vector4>(
this.workerHeight,
destWidth,
AllocationOptions.Clean);
preferContiguosImageBuffers: true,
options: AllocationOptions.Clean);
this.tempRowBuffer = configuration.MemoryAllocator.Allocate<Vector4>(this.sourceRectangle.Width);
this.tempColumnBuffer = configuration.MemoryAllocator.Allocate<Vector4>(destWidth);

12
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<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
provider.LimitAllocatorBufferCapacity().InBytes(1000);
provider.RunValidatingProcessorTest(
x => x.Resize(30, 30),
appendPixelTypeToFileName: false,
appendSourceFileOrDescription: false);
}
}
}

3
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
Loading…
Cancel
Save