Browse Source

StyleCop fixes.

af/merge-core
Dirk Lemstra 10 years ago
parent
commit
0447fd89cc
  1. 14
      src/ImageSharp/Profiles/Exif/ExifReader.cs
  2. 138
      src/ImageSharp/Profiles/Exif/ExifValue.cs
  3. 4
      src/ImageSharp/Profiles/Exif/ExifWriter.cs
  4. 34
      src/ImageSharp/Samplers/Processors/RotateProcessor.cs

14
src/ImageSharp/Profiles/Exif/ExifReader.cs

@ -15,8 +15,6 @@ namespace ImageSharp
/// </summary>
internal sealed class ExifReader
{
private delegate TDataType ConverterMethod<TDataType>(byte[] data);
private readonly Collection<ExifTag> invalidTags = new Collection<ExifTag>();
private byte[] exifData;
private uint currentIndex;
@ -25,6 +23,13 @@ namespace ImageSharp
private uint gpsOffset;
private uint startIndex;
private delegate TDataType ConverterMethod<TDataType>(byte[] data);
/// <summary>
/// Gets the invalid tags.
/// </summary>
public IEnumerable<ExifTag> InvalidTags => this.invalidTags;
/// <summary>
/// Gets the thumbnail length in the byte stream
/// </summary>
@ -112,11 +117,6 @@ namespace ImageSharp
return result;
}
/// <summary>
/// Gets the invalid tags.
/// </summary>
public IEnumerable<ExifTag> InvalidTags => this.invalidTags;
/// <summary>
/// Adds the collection of EXIF values to the reader.
/// </summary>

138
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;
}
/// <summary>
/// Gets the data type of the exif value.
/// </summary>
@ -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;
}
}
/// <summary>
/// Determines whether the specified ExifValue instances are considered equal.
/// </summary>
@ -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");

4
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<ExifValue> values;
private Collection<int> dataOffsets;

34
src/ImageSharp/Samplers/Processors/RotateProcessor.cs

@ -33,23 +33,6 @@ namespace ImageSharp.Processors
/// </summary>
public bool Expand { get; set; } = true;
/// <inheritdoc/>
protected override void OnApply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> 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);
}
}
/// <inheritdoc/>
public override void Apply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
{
@ -83,6 +66,23 @@ namespace ImageSharp.Processors
}
}
/// <inheritdoc/>
protected override void OnApply(ImageBase<TColor, TPacked> target, ImageBase<TColor, TPacked> 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);
}
}
/// <summary>
/// Rotates the images with an optimized method when the angle is 90, 180 or 270 degrees.
/// </summary>

Loading…
Cancel
Save