Browse Source

Fix Stylecop SA1028

pull/33/head
James Jackson-South 10 years ago
parent
commit
9ef19c951d
  1. 2
      src/ImageSharp/Colors/ColorConstants.cs
  2. 3
      src/ImageSharp/Colors/Colorspaces/CieLab.cs
  3. 1
      src/ImageSharp/Colors/PackedPixel/HalfTypeHelper.cs
  4. 2
      src/ImageSharp/Filters/Processors/ColorMatrix/GrayscaleBt709Processor.cs
  5. 16
      src/ImageSharp/Image/PixelAccessor.cs
  6. 16
      src/ImageSharp/Image/PixelRow.cs
  7. 2
      src/ImageSharp/ImageFrame.cs
  8. 4
      src/ImageSharp/PixelAccessor.cs

2
src/ImageSharp/Colors/ColorConstants.cs

@ -26,7 +26,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Returns an array of web safe colors. /// Returns an array of web safe colors.
/// </summary> /// </summary>
/// <returns></returns> /// <returns>The <see cref="T:Color[]"/></returns>
private static Color[] GetWebSafeColors() private static Color[] GetWebSafeColors()
{ {
return new List<Color> return new List<Color>

3
src/ImageSharp/Colors/Colorspaces/CieLab.cs

@ -86,7 +86,8 @@ namespace ImageSharp
// Now to LAB // Now to LAB
x /= 0.95047F; x /= 0.95047F;
//y /= 1F;
// y /= 1F;
z /= 1.08883F; z /= 1.08883F;
x = x > 0.008856F ? (float)Math.Pow(x, 0.3333333F) : ((903.3F * x) + 16F) / 116F; x = x > 0.008856F ? (float)Math.Pow(x, 0.3333333F) : ((903.3F * x) + 16F) / 116F;

1
src/ImageSharp/Colors/PackedPixel/HalfTypeHelper.cs

@ -99,6 +99,7 @@ namespace ImageSharp
exponent--; exponent--;
mantissa = mantissa << 1; mantissa = mantissa << 1;
} }
mantissa &= 0xfffffbff; mantissa &= 0xfffffbff;
result = ((uint)((((uint)value & 0x8000) << 16) | ((exponent + 127) << 23))) | (mantissa << 13); result = ((uint)((((uint)value & 0x8000) << 16) | ((exponent + 127) << 23))) | (mantissa << 13);
} }

2
src/ImageSharp/Filters/Processors/ColorMatrix/GrayscaleBt709Processor.cs

@ -11,6 +11,8 @@ namespace ImageSharp.Processors
/// Converts the colors of the image to Grayscale applying the formula as specified by /// Converts the colors of the image to Grayscale applying the formula as specified by
/// ITU-R Recommendation BT.709 <see href="https://en.wikipedia.org/wiki/Rec._709#Luma_coefficients"/>. /// ITU-R Recommendation BT.709 <see href="https://en.wikipedia.org/wiki/Rec._709#Luma_coefficients"/>.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public class GrayscaleBt709Processor<TColor, TPacked> : ColorMatrixFilter<TColor, TPacked> public class GrayscaleBt709Processor<TColor, TPacked> : ColorMatrixFilter<TColor, TPacked>
where TColor : struct, IPackedPixel<TPacked> where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct where TPacked : struct

16
src/ImageSharp/Image/PixelAccessor.cs

@ -254,6 +254,14 @@ namespace ImageSharp
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
/// <summary>
/// Resets all the pixels to it's initial value.
/// </summary>
internal void Reset()
{
Unsafe.InitBlock(this.pixelsBase, 0, (uint)(this.RowStride * this.Height));
}
/// <summary> /// <summary>
/// Copies from a row in <see cref="ComponentOrder.ZYX"/> format. /// Copies from a row in <see cref="ComponentOrder.ZYX"/> format.
/// </summary> /// </summary>
@ -429,13 +437,5 @@ namespace ImageSharp
{ {
return this.pixelsBase + ((targetY * this.Width) * Unsafe.SizeOf<TColor>()); return this.pixelsBase + ((targetY * this.Width) * Unsafe.SizeOf<TColor>());
} }
/// <summary>
/// Resets all the pixels to it's initial value.
/// </summary>
internal void Reset()
{
Unsafe.InitBlock(this.pixelsBase, 0, (uint)(this.RowStride * this.Height));
}
} }
} }

16
src/ImageSharp/Image/PixelRow.cs

@ -178,6 +178,14 @@ namespace ImageSharp
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
/// <summary>
/// Resets the bytes of the array to it's initial value.
/// </summary>
internal void Reset()
{
Unsafe.InitBlock(this.PixelBase, 0, (uint)this.Bytes.Length);
}
/// <summary> /// <summary>
/// Gets component count for the given order. /// Gets component count for the given order.
/// </summary> /// </summary>
@ -202,13 +210,5 @@ namespace ImageSharp
throw new NotSupportedException(); throw new NotSupportedException();
} }
/// <summary>
/// Resets the bytes of the array to it's initial value.
/// </summary>
internal void Reset()
{
Unsafe.InitBlock(this.PixelBase, 0, (uint)this.Bytes.Length);
}
} }
} }

2
src/ImageSharp/ImageFrame.cs

@ -1,4 +1,4 @@
// <copyright file="Image.cs" company="James Jackson-South"> // <copyright file="ImageFrame.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors. // Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright> // </copyright>

4
src/ImageSharp/PixelAccessor.cs

@ -27,7 +27,7 @@ namespace ImageSharp
byte* source = row.PixelBase; byte* source = row.PixelBase;
byte* destination = this.GetRowPointer(targetY) + targetX; byte* destination = this.GetRowPointer(targetY) + targetX;
Unsafe.CopyBlock(destination, source, (uint) width * 4); Unsafe.CopyBlock(destination, source, (uint)width * 4);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -38,7 +38,7 @@ namespace ImageSharp
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
Unsafe.Write(destination, (uint)(*(source) << 0 | *(source + 1) << 8 | *(source + 2) << 16 | 255 << 24)); Unsafe.Write(destination, (uint)(*source << 0 | *(source + 1) << 8 | *(source + 2) << 16 | 255 << 24));
source += 3; source += 3;
destination += 4; destination += 4;

Loading…
Cancel
Save