Browse Source

Little bit of cleanup

pull/33/head
James Jackson-South 10 years ago
parent
commit
0988708ac9
  1. 3
      src/ImageSharp/Formats/Jpg/Components/Huffman.cs
  2. 1
      src/ImageSharp/Formats/Jpg/Components/MutableSpan.cs
  3. 6
      src/ImageSharp/Formats/Jpg/JpegDecoderCore.cs
  4. 3
      src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs
  5. 4
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  6. 24
      src/ImageSharp/Profiles/Exif/ExifValue.cs
  7. 13
      src/ImageSharp/Profiles/Exif/ExifWriter.cs

3
src/ImageSharp/Formats/Jpg/Components/Huffman.cs

@ -23,9 +23,8 @@ namespace ImageSharp.Formats
this.Lut = UshortBuffer.Rent(1 << lutSize); this.Lut = UshortBuffer.Rent(1 << lutSize);
this.Values = ByteBuffer.Rent(maxNCodes); this.Values = ByteBuffer.Rent(maxNCodes);
this.MinCodes = IntBuffer.Rent(maxCodeLength); this.MinCodes = IntBuffer.Rent(maxCodeLength);
this.MaxCodes = IntBuffer.Rent(maxCodeLength); this.MaxCodes = IntBuffer.Rent(maxCodeLength);
this.Indices = IntBuffer.Rent(maxCodeLength); this.Indices = IntBuffer.Rent(maxCodeLength);
} }
/// <summary> /// <summary>

1
src/ImageSharp/Formats/Jpg/Components/MutableSpan.cs

@ -43,6 +43,7 @@ namespace ImageSharp.Formats
{ {
return this.Data[idx + this.Offset]; return this.Data[idx + this.Offset];
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
set set
{ {

6
src/ImageSharp/Formats/Jpg/JpegDecoderCore.cs

@ -89,7 +89,6 @@ namespace ImageSharp.Formats
/// <summary> /// <summary>
/// The huffman trees /// The huffman trees
/// </summary> /// </summary>
//private readonly Huffman[,] huffmanTrees;
private readonly Huffman[] huffmanTrees; private readonly Huffman[] huffmanTrees;
/// <summary> /// <summary>
@ -1310,7 +1309,7 @@ namespace ImageSharp.Formats
struct StackallocUnzigData struct StackallocUnzigData
{ {
internal fixed int Data [64]; internal fixed int Data[64];
} }
/// <summary> /// <summary>
@ -1508,7 +1507,7 @@ namespace ImageSharp.Formats
fixed (Block8x8F* qtp = &this.quantizationTables[qtIndex]) fixed (Block8x8F* qtp = &this.quantizationTables[qtIndex])
{ {
if (this.isProgressive) if (this.isProgressive)
// Load the previous partially decoded coefficients, if applicable. // Load the previous partially decoded coefficients, if applicable.
{ {
this.blockIndex = ((@by * mxx) * hi) + bx; this.blockIndex = ((@by * mxx) * hi) + bx;
@ -2172,6 +2171,7 @@ namespace ImageSharp.Formats
{ {
this.huffmanTrees[i].Dispose(); this.huffmanTrees[i].Dispose();
} }
this.bytes.Dispose(); this.bytes.Dispose();
} }
} }

3
src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs

@ -542,10 +542,11 @@ namespace ImageSharp.Formats
/// <param name="crBlock">The blue chroma block.</param> /// <param name="crBlock">The blue chroma block.</param>
// ReSharper disable StyleCop.SA1305 // ReSharper disable StyleCop.SA1305
private void ToYCbCr<TColor, TPacked>(PixelAccessor<TColor, TPacked> pixels, int x, int y, ref Block yBlock, ref Block cbBlock, ref Block crBlock) private void ToYCbCr<TColor, TPacked>(PixelAccessor<TColor, TPacked> pixels, int x, int y, ref Block yBlock, ref Block cbBlock, ref Block crBlock)
// ReSharper restore StyleCop.SA1305
where TColor : struct, IPackedPixel<TPacked> where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct where TPacked : struct
{ {
// ReSharper restore StyleCop.SA1305
int xmax = pixels.Width - 1; int xmax = pixels.Width - 1;
int ymax = pixels.Height - 1; int ymax = pixels.Height - 1;
byte[] color = new byte[3]; byte[] color = new byte[3];

4
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -30,12 +30,12 @@ namespace ImageSharp.Formats
private static readonly int[] Adam7ColumnIncrement = { 8, 8, 4, 4, 2, 2, 1 }; private static readonly int[] Adam7ColumnIncrement = { 8, 8, 4, 4, 2, 2, 1 };
/// <summary> /// <summary>
/// The index to start at when processing each column per scanline for each interlaced pass /// The index to start at when processing each column per scanline for each interlaced pass
/// </summary> /// </summary>
private static readonly int[] Adam7FirstColumn = { 0, 4, 0, 2, 0, 1, 0 }; private static readonly int[] Adam7FirstColumn = { 0, 4, 0, 2, 0, 1, 0 };
/// <summary> /// <summary>
/// The index to start at when processing each row per scanline for each interlaced pass /// The index to start at when processing each row per scanline for each interlaced pass
/// </summary> /// </summary>
private static readonly int[] Adam7FirstRow = { 0, 0, 4, 0, 2, 0, 1 }; private static readonly int[] Adam7FirstRow = { 0, 0, 4, 0, 2, 0, 1 };

24
src/ImageSharp/Profiles/Exif/ExifValue.cs

@ -155,7 +155,7 @@ namespace ImageSharp
/// </summary> /// </summary>
/// <param name="left">The first ExifValue to compare.</param> /// <param name="left">The first ExifValue to compare.</param>
/// <param name="right"> The second ExifValue to compare.</param> /// <param name="right"> The second ExifValue to compare.</param>
/// <returns></returns> /// <returns>The <see cref="bool"/></returns>
public static bool operator ==(ExifValue left, ExifValue right) public static bool operator ==(ExifValue left, ExifValue right)
{ {
return Equals(left, right); return Equals(left, right);
@ -172,10 +172,7 @@ namespace ImageSharp
return !Equals(left, right); return !Equals(left, right);
} }
/// <summary> /// <inheritdoc />
/// Determines whether the specified object is equal to the current exif value.
/// </summary>
/// <param name="obj">The object to compare this exif value with.</param>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(this, obj)) if (ReferenceEquals(this, obj))
@ -186,10 +183,7 @@ namespace ImageSharp
return this.Equals(obj as ExifValue); return this.Equals(obj as ExifValue);
} }
/// <summary> /// <inheritdoc />
/// Determines whether the specified exif value is equal to the current exif value.
/// </summary>
/// <param name="other">The exif value to compare this exif value with.</param>
public bool Equals(ExifValue other) public bool Equals(ExifValue other)
{ {
if (ReferenceEquals(other, null)) if (ReferenceEquals(other, null))
@ -205,7 +199,7 @@ namespace ImageSharp
return return
this.Tag == other.Tag && this.Tag == other.Tag &&
this.DataType == other.DataType && this.DataType == other.DataType &&
Equals(this.exifValue, other.exifValue); object.Equals(this.exifValue, other.exifValue);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -549,6 +543,16 @@ namespace ImageSharp
return exifValue; return exifValue;
} }
/// <summary>
/// Gets the size in bytes of the given data type.
/// </summary>
/// <param name="dataType">The data type.</param>
/// <returns>
/// The <see cref="uint"/>.
/// </returns>
/// <exception cref="NotSupportedException">
/// Thrown if the type is unsupported.
/// </exception>
internal static uint GetSize(ExifDataType dataType) internal static uint GetSize(ExifDataType dataType)
{ {
switch (dataType) switch (dataType)

13
src/ImageSharp/Profiles/Exif/ExifWriter.cs

@ -283,6 +283,11 @@ namespace ImageSharp
private Collection<int> exifIndexes; private Collection<int> exifIndexes;
private Collection<int> gpsIndexes; private Collection<int> gpsIndexes;
/// <summary>
/// Initializes a new instance of the <see cref="ExifWriter"/> class.
/// </summary>
/// <param name="values">The values.</param>
/// <param name="allowedParts">The allowed parts.</param>
public ExifWriter(Collection<ExifValue> values, ExifParts allowedParts) public ExifWriter(Collection<ExifValue> values, ExifParts allowedParts)
{ {
this.values = values; this.values = values;
@ -292,9 +297,15 @@ namespace ImageSharp
this.gpsIndexes = this.GetIndexes(ExifParts.GPSTags, GPSTags); this.gpsIndexes = this.GetIndexes(ExifParts.GPSTags, GPSTags);
} }
/// <summary>
/// Returns the EXIF data.
/// </summary>
/// <returns>
/// The <see cref="T:byte[]"/>.
/// </returns>
public byte[] GetData() public byte[] GetData()
{ {
uint length = 0; uint length;
int exifIndex = -1; int exifIndex = -1;
int gpsIndex = -1; int gpsIndex = -1;

Loading…
Cancel
Save