diff --git a/src/ImageSharp/Profiles/Exif/ExifReader.cs b/src/ImageSharp/Profiles/Exif/ExifReader.cs index 7bbfb3d061..2015b9acb7 100644 --- a/src/ImageSharp/Profiles/Exif/ExifReader.cs +++ b/src/ImageSharp/Profiles/Exif/ExifReader.cs @@ -15,8 +15,6 @@ namespace ImageSharp /// internal sealed class ExifReader { - private delegate TDataType ConverterMethod(byte[] data); - private readonly Collection invalidTags = new Collection(); private byte[] exifData; private uint currentIndex; @@ -25,6 +23,13 @@ namespace ImageSharp private uint gpsOffset; private uint startIndex; + private delegate TDataType ConverterMethod(byte[] data); + + /// + /// Gets the invalid tags. + /// + public IEnumerable InvalidTags => this.invalidTags; + /// /// Gets the thumbnail length in the byte stream /// @@ -112,11 +117,6 @@ namespace ImageSharp return result; } - /// - /// Gets the invalid tags. - /// - public IEnumerable InvalidTags => this.invalidTags; - /// /// Adds the collection of EXIF values to the reader. /// diff --git a/src/ImageSharp/Profiles/Exif/ExifValue.cs b/src/ImageSharp/Profiles/Exif/ExifValue.cs index db62be4c23..069df7b48d 100644 --- a/src/ImageSharp/Profiles/Exif/ExifValue.cs +++ b/src/ImageSharp/Profiles/Exif/ExifValue.cs @@ -41,6 +41,24 @@ namespace ImageSharp } } + internal ExifValue(ExifTag tag, ExifDataType dataType, bool isArray) + { + this.Tag = tag; + this.DataType = dataType; + this.IsArray = isArray; + + if (dataType == ExifDataType.Ascii) + { + this.IsArray = false; + } + } + + internal ExifValue(ExifTag tag, ExifDataType dataType, object value, bool isArray) + : this(tag, dataType, isArray) + { + this.exifValue = value; + } + /// /// Gets the data type of the exif value. /// @@ -81,6 +99,57 @@ namespace ImageSharp } } + internal bool HasValue + { + get + { + if (this.exifValue == null) + { + return false; + } + + if (this.DataType == ExifDataType.Ascii) + { + return ((string)this.exifValue).Length > 0; + } + + return true; + } + } + + internal int Length + { + get + { + if (this.exifValue == null) + { + return 4; + } + + int size = (int)(GetSize(this.DataType) * this.NumberOfComponents); + + return size < 4 ? 4 : size; + } + } + + internal int NumberOfComponents + { + get + { + if (this.DataType == ExifDataType.Ascii) + { + return Encoding.UTF8.GetBytes((string)this.exifValue).Length; + } + + if (this.IsArray) + { + return ((Array)this.exifValue).Length; + } + + return 1; + } + } + /// /// Determines whether the specified ExifValue instances are considered equal. /// @@ -173,75 +242,6 @@ namespace ImageSharp return sb.ToString(); } - internal bool HasValue - { - get - { - if (this.exifValue == null) - { - return false; - } - - if (this.DataType == ExifDataType.Ascii) - { - return ((string)this.exifValue).Length > 0; - } - - return true; - } - } - - internal int Length - { - get - { - if (this.exifValue == null) - { - return 4; - } - - int size = (int)(GetSize(this.DataType) * this.NumberOfComponents); - - return size < 4 ? 4 : size; - } - } - - internal int NumberOfComponents - { - get - { - if (this.DataType == ExifDataType.Ascii) - { - return Encoding.UTF8.GetBytes((string)this.exifValue).Length; - } - - if (this.IsArray) - { - return ((Array)this.exifValue).Length; - } - - return 1; - } - } - - internal ExifValue(ExifTag tag, ExifDataType dataType, bool isArray) - { - this.Tag = tag; - this.DataType = dataType; - this.IsArray = isArray; - - if (dataType == ExifDataType.Ascii) - { - this.IsArray = false; - } - } - - internal ExifValue(ExifTag tag, ExifDataType dataType, object value, bool isArray) - : this(tag, dataType, isArray) - { - this.exifValue = value; - } - internal static ExifValue Create(ExifTag tag, object value) { Guard.IsFalse(tag == ExifTag.Unknown, nameof(tag), "Invalid Tag"); diff --git a/src/ImageSharp/Profiles/Exif/ExifWriter.cs b/src/ImageSharp/Profiles/Exif/ExifWriter.cs index f7653b240f..8c82dbdf77 100644 --- a/src/ImageSharp/Profiles/Exif/ExifWriter.cs +++ b/src/ImageSharp/Profiles/Exif/ExifWriter.cs @@ -12,6 +12,8 @@ namespace ImageSharp internal sealed class ExifWriter { + private const int StartIndex = 6; + private static readonly ExifTag[] IfdTags = new ExifTag[127] { ExifTag.SubfileType, @@ -274,8 +276,6 @@ namespace ImageSharp ExifTag.GPSDifferential }; - private const int StartIndex = 6; - private ExifParts allowedParts; private Collection values; private Collection dataOffsets; diff --git a/src/ImageSharp/Samplers/Processors/RotateProcessor.cs b/src/ImageSharp/Samplers/Processors/RotateProcessor.cs index 05cbda36e8..a9e69678df 100644 --- a/src/ImageSharp/Samplers/Processors/RotateProcessor.cs +++ b/src/ImageSharp/Samplers/Processors/RotateProcessor.cs @@ -33,23 +33,6 @@ namespace ImageSharp.Processors /// public bool Expand { get; set; } = true; - /// - protected override void OnApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle) - { - const float Epsilon = .0001F; - - if (Math.Abs(this.Angle) < Epsilon || Math.Abs(this.Angle - 90) < Epsilon || Math.Abs(this.Angle - 180) < Epsilon || Math.Abs(this.Angle - 270) < Epsilon) - { - return; - } - - this.processMatrix = Point.CreateRotation(new Point(0, 0), -this.Angle); - if (this.Expand) - { - CreateNewTarget(target, sourceRectangle, this.processMatrix); - } - } - /// public override void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY) { @@ -83,6 +66,23 @@ namespace ImageSharp.Processors } } + /// + protected override void OnApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle) + { + const float Epsilon = .0001F; + + if (Math.Abs(this.Angle) < Epsilon || Math.Abs(this.Angle - 90) < Epsilon || Math.Abs(this.Angle - 180) < Epsilon || Math.Abs(this.Angle - 270) < Epsilon) + { + return; + } + + this.processMatrix = Point.CreateRotation(new Point(0, 0), -this.Angle); + if (this.Expand) + { + CreateNewTarget(target, sourceRectangle, this.processMatrix); + } + } + /// /// Rotates the images with an optimized method when the angle is 90, 180 or 270 degrees. ///