Browse Source

Merge pull request #43 from olivif/olivif/fixwarnings

Adding missing documentation and fixing style issues.
pull/45/head
James Jackson-South 9 years ago
committed by GitHub
parent
commit
25ec9cea02
  1. 1
      src/ImageSharp/Colors/PackedPixel/IPackedPixel.cs
  2. 4
      src/ImageSharp/Drawing/Brushes/Brushes`2.cs
  3. 6
      src/ImageSharp/Drawing/Brushes/PatternBrush`2.cs
  4. 1
      src/ImageSharp/Drawing/Draw.cs
  5. 2
      src/ImageSharp/Drawing/DrawImage.cs
  6. 1
      src/ImageSharp/Drawing/Fill.cs
  7. 8
      src/ImageSharp/Drawing/Processors/DrawPathProcessor.cs
  8. 3
      src/ImageSharp/Drawing/Processors/FillShapeProcessor.cs
  9. 2
      src/ImageSharp/Drawing/Shapes/LinearPolygon.cs
  10. 13
      src/ImageSharp/Formats/Gif/GifEncoderCore.cs
  11. 9
      src/ImageSharp/Formats/Jpg/Components/Bits.cs
  12. 75
      src/ImageSharp/Formats/Jpg/Components/Block8x8F.cs
  13. 5
      src/ImageSharp/Formats/Jpg/Components/Bytes.cs
  14. 2
      src/ImageSharp/Formats/Jpg/JpegDecoderCore.cs

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

@ -6,6 +6,7 @@
namespace ImageSharp
{
using System;
/// <summary>
/// An interface that represents a packed pixel type.
/// </summary>

4
src/ImageSharp/Drawing/Brushes/Brushes`2.cs

@ -3,10 +3,10 @@
// Licensed under the Apache License, Version 2.0.
// </copyright>
using System;
namespace ImageSharp.Drawing.Brushes
{
using System;
/// <summary>
/// A collection of methods for creating generic brushes.
/// </summary>

6
src/ImageSharp/Drawing/Brushes/PatternBrush`2.cs

@ -5,10 +5,10 @@
namespace ImageSharp.Drawing.Brushes
{
using System;
using System.Numerics;
using Processors;
using System;
/// <summary>
/// Provides an implementation of a pattern brush for painting patterns.
@ -30,12 +30,12 @@ namespace ImageSharp.Drawing.Brushes
/// 0
/// 0
/// </para>
/// Warning when use array initializer across multiple lines the bools look inverted i.e.
/// Warning when use array initializer across multiple lines the bools look inverted i.e.
/// new bool[,]{
/// {true, false, false},
/// {false,true, false}
/// }
/// would be
/// would be
/// 10
/// 01
/// 00

1
src/ImageSharp/Drawing/Draw.cs

@ -220,6 +220,7 @@ namespace ImageSharp
{
return source.DrawPolygon(pen, new Polygon(new LinearLineSegment(points)), options);
}
/// <summary>
/// Draws the provided Points as a closed Linear Polygon with the provided Pen.
/// </summary>

2
src/ImageSharp/Drawing/DrawImage.cs

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

1
src/ImageSharp/Drawing/Fill.cs

@ -56,6 +56,7 @@ namespace ImageSharp
/// <param name="source">The source.</param>
/// <param name="brush">The brush.</param>
/// <param name="shape">The shape.</param>
/// <param name="options">The graphics options.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> Fill<TColor, TPacked>(this Image<TColor, TPacked> source, IBrush<TColor, TPacked> brush, IShape shape, GraphicsOptions options)
where TColor : struct, IPackedPixel<TPacked>

8
src/ImageSharp/Drawing/Processors/DrawPathProcessor.cs

@ -34,7 +34,7 @@ namespace ImageSharp.Drawing.Processors
private readonly IPath[] paths;
private readonly RectangleF region;
private readonly GraphicsOptions options;
/// <summary>
/// Initializes a new instance of the <see cref="DrawPathProcessor{TColor, TPacked}" /> class.
/// </summary>
@ -56,7 +56,7 @@ namespace ImageSharp.Drawing.Processors
: this(pen, new[] { path }, options)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DrawPathProcessor{TColor, TPacked}" /> class.
/// </summary>
@ -134,10 +134,10 @@ namespace ImageSharp.Drawing.Processors
currentPoint.X = offsetX;
currentPoint.Y = offsetY;
var dist = Closest(currentPoint);
var dist = this.Closest(currentPoint);
var color = applicator.GetColor(dist);
var opacity = this.Opacity(color.DistanceFromElement);
if (opacity > Epsilon)

3
src/ImageSharp/Drawing/Processors/FillShapeProcessor.cs

@ -35,6 +35,7 @@ namespace ImageSharp.Drawing.Processors
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="shape">The shape.</param>
/// <param name="options">The graphics options.</param>
public FillShapeProcessor(IBrush<TColor, TPacked> brush, IShape shape, GraphicsOptions options)
{
this.poly = shape;
@ -73,7 +74,7 @@ namespace ImageSharp.Drawing.Processors
{
polyStartY = 0;
}
using (PixelAccessor<TColor, TPacked> sourcePixels = source.Lock())
using (IBrushApplicator<TColor, TPacked> applicator = this.fillColor.CreateApplicator(rect))
{

2
src/ImageSharp/Drawing/Shapes/LinearPolygon.cs

@ -25,7 +25,7 @@ namespace ImageSharp.Drawing.Shapes
{
this.innerPolygon = new Polygon(new LinearLineSegment(points));
}
/// <summary>
/// Gets the bounding box of this shape.
/// </summary>

13
src/ImageSharp/Formats/Gif/GifEncoderCore.cs

@ -53,7 +53,8 @@ namespace ImageSharp.Formats
/// <param name="image">The <see cref="Image{TColor, TPacked}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
public void Encode<TColor, TPacked>(Image<TColor, TPacked> image, Stream stream)
where TColor : struct, IPackedPixel<TPacked> where TPacked : struct, IEquatable<TPacked>
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct, IEquatable<TPacked>
{
Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream));
@ -121,7 +122,8 @@ namespace ImageSharp.Formats
/// The <see cref="int"/>.
/// </returns>
private static int GetTransparentIndex<TColor, TPacked>(QuantizedImage<TColor, TPacked> quantized)
where TColor : struct, IPackedPixel<TPacked> where TPacked : struct, IEquatable<TPacked>
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct, IEquatable<TPacked>
{
// Find the lowest alpha value and make it the transparent index.
int index = -1;
@ -236,7 +238,9 @@ namespace ImageSharp.Formats
private void WriteGraphicalControlExtension<TColor, TPacked>(
ImageBase<TColor, TPacked> image,
EndianBinaryWriter writer,
int transparencyIndex) where TColor : struct, IPackedPixel<TPacked> where TPacked : struct, IEquatable<TPacked>
int transparencyIndex)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct, IEquatable<TPacked>
{
// TODO: Check transparency logic.
bool hasTransparent = transparencyIndex > -1;
@ -281,7 +285,8 @@ namespace ImageSharp.Formats
/// <param name="image">The <see cref="ImageBase{TColor, TPacked}"/> to be encoded.</param>
/// <param name="writer">The stream to write to.</param>
private void WriteImageDescriptor<TColor, TPacked>(ImageBase<TColor, TPacked> image, EndianBinaryWriter writer)
where TColor : struct, IPackedPixel<TPacked> where TPacked : struct, IEquatable<TPacked>
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct, IEquatable<TPacked>
{
writer.Write(GifConstants.ImageDescriptorLabel); // 2c
// TODO: Can we capture this?

9
src/ImageSharp/Formats/Jpg/Components/Bits.cs

@ -36,7 +36,8 @@ namespace ImageSharp.Formats
/// the caller is the one responsible for first checking that bits.UnreadBits &lt; n.
/// </summary>
/// <param name="n">The number of bits to ensure.</param>
/// <param name="decoder"></param>
/// <param name="decoder">Jpeg decoder</param>
/// <returns>Error code</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal JpegDecoderCore.ErrorCodes EnsureNBits(int n, JpegDecoderCore decoder)
{
@ -69,6 +70,12 @@ namespace ImageSharp.Formats
}
}
/// <summary>
/// Receive extend
/// </summary>
/// <param name="t">Byte</param>
/// <param name="decoder">Jpeg decoder</param>
/// <returns>Read bits value</returns>
internal int ReceiveExtend(byte t, JpegDecoderCore decoder)
{
if (this.UnreadBits < t)

75
src/ImageSharp/Formats/Jpg/Components/Block8x8F.cs

@ -85,6 +85,8 @@ namespace ImageSharp.Formats
/// <summary>
/// Load raw 32bit floating point data from source
/// </summary>
/// <param name="blockPtr">Block pointer</param>
/// <param name="source">Source</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void LoadFrom(Block8x8F* blockPtr, MutableSpan<float> source)
{
@ -94,6 +96,8 @@ namespace ImageSharp.Formats
/// <summary>
/// Copy raw 32bit floating point data to dest
/// </summary>
/// <param name="blockPtr">Block pointer</param>
/// <param name="dest">Destination</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void CopyTo(Block8x8F* blockPtr, MutableSpan<float> dest)
{
@ -103,6 +107,7 @@ namespace ImageSharp.Formats
/// <summary>
/// Load raw 32bit floating point data from source
/// </summary>
/// <param name="source">Source</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void LoadFrom(MutableSpan<float> source)
{
@ -115,6 +120,7 @@ namespace ImageSharp.Formats
/// <summary>
/// Copy raw 32bit floating point data to dest
/// </summary>
/// <param name="dest">Destination</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void CopyTo(MutableSpan<float> dest)
{
@ -127,6 +133,7 @@ namespace ImageSharp.Formats
/// <summary>
/// Copy raw 32bit floating point data to dest
/// </summary>
/// <param name="dest">Destination</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void CopyTo(float[] dest)
{
@ -161,17 +168,17 @@ namespace ImageSharp.Formats
/// Apply floating point IDCT transformation into dest, using a temporary block 'temp' provided by the caller (optimization)
/// </summary>
/// <param name="dest">Destination</param>
/// <param name="temp">Temporary block provided by the caller</param>
public void TransformIDCTInto(ref Block8x8F dest, ref Block8x8F temp)
/// <param name="tempBlockPtr">Temporary block provided by the caller</param>
public void TransformIDCTInto(ref Block8x8F dest, ref Block8x8F tempBlockPtr)
{
this.TransposeInto(ref temp);
temp.IDCT8x4_LeftPart(ref dest);
temp.IDCT8x4_RightPart(ref dest);
this.TransposeInto(ref tempBlockPtr);
tempBlockPtr.IDCT8x4_LeftPart(ref dest);
tempBlockPtr.IDCT8x4_RightPart(ref dest);
dest.TransposeInto(ref temp);
dest.TransposeInto(ref tempBlockPtr);
temp.IDCT8x4_LeftPart(ref dest);
temp.IDCT8x4_RightPart(ref dest);
tempBlockPtr.IDCT8x4_LeftPart(ref dest);
tempBlockPtr.IDCT8x4_RightPart(ref dest);
dest.MultiplyAllInplace(C_0_125);
}
@ -179,6 +186,9 @@ namespace ImageSharp.Formats
/// <summary>
/// Pointer-based "Indexer" (getter part)
/// </summary>
/// <param name="blockPtr">Block pointer</param>
/// <param name="idx">Index</param>
/// <returns>The scalar value at the specified index</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe float GetScalarAt(Block8x8F* blockPtr, int idx)
{
@ -189,6 +199,9 @@ namespace ImageSharp.Formats
/// <summary>
/// Pointer-based "Indexer" (setter part)
/// </summary>
/// <param name="blockPtr">Block pointer</param>
/// <param name="idx">Index</param>
/// <param name="value">Value</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe void SetScalarAt(Block8x8F* blockPtr, int idx, float value)
{
@ -196,11 +209,17 @@ namespace ImageSharp.Formats
fp[idx] = value;
}
/// <summary>
/// Un-zig
/// </summary>
/// <param name="blockPtr">Block pointer</param>
/// <param name="qtPtr">Qt pointer</param>
/// <param name="unzigPtr">Unzig pointer</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe void UnZig(Block8x8F* block, Block8x8F* qt, int* unzigPtr)
internal static unsafe void UnZig(Block8x8F* blockPtr, Block8x8F* qtPtr, int* unzigPtr)
{
float* b = (float*)block;
float* qtp = (float*)qt;
float* b = (float*)blockPtr;
float* qtp = (float*)qtPtr;
for (int zig = 0; zig < BlockF.BlockSize; zig++)
{
float* unzigPos = b + unzigPtr[zig];
@ -213,6 +232,7 @@ namespace ImageSharp.Formats
/// <summary>
/// Copy raw 32bit floating point data to dest
/// </summary>
/// <param name="dest">Destination</param>
internal unsafe void CopyTo(MutableSpan<int> dest)
{
fixed (Vector4* ptr = &this.V0L)
@ -228,6 +248,7 @@ namespace ImageSharp.Formats
/// <summary>
/// Load raw 32bit floating point data from source
/// </summary>
/// <param name="source">Source</param>
internal unsafe void LoadFrom(MutableSpan<int> source)
{
fixed (Vector4* ptr = &this.V0L)
@ -301,8 +322,9 @@ namespace ImageSharp.Formats
/// Original source:
/// https://github.com/norishigefukushima/dct_simd/blob/master/dct/dct8x8_simd.cpp#L261
/// </summary>
/// <param name="destBlockPtr">Destination Block pointer</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void IDCT8x4_RightPart(ref Block8x8F d)
internal void IDCT8x4_RightPart(ref Block8x8F destBlockPtr)
{
Vector4 my1 = this.V1R;
Vector4 my7 = this.V7R;
@ -342,14 +364,14 @@ namespace ImageSharp.Formats
my1 = mz1 + mz2;
my2 = mz1 - mz2;
d.V0R = my0 + mb0;
d.V7R = my0 - mb0;
d.V1R = my1 + mb1;
d.V6R = my1 - mb1;
d.V2R = my2 + mb2;
d.V5R = my2 - mb2;
d.V3R = my3 + mb3;
d.V4R = my3 - mb3;
destBlockPtr.V0R = my0 + mb0;
destBlockPtr.V7R = my0 - mb0;
destBlockPtr.V1R = my1 + mb1;
destBlockPtr.V6R = my1 - mb1;
destBlockPtr.V2R = my2 + mb2;
destBlockPtr.V5R = my2 - mb2;
destBlockPtr.V3R = my3 + mb3;
destBlockPtr.V4R = my3 - mb3;
}
/// <summary>
@ -365,7 +387,7 @@ namespace ImageSharp.Formats
/// <summary>
/// TODO: Should be removed when BlockF goes away
/// </summary>
/// <param name="legacyBlock"></param>
/// <param name="legacyBlock">Legacy block</param>
internal void LoadFrom(ref BlockF legacyBlock)
{
this.LoadFrom(legacyBlock.Data);
@ -374,7 +396,7 @@ namespace ImageSharp.Formats
/// <summary>
/// TODO: Should be removed when BlockF goes away
/// </summary>
/// <param name="legacyBlock"></param>
/// <param name="legacyBlock">Legacy block</param>
internal void CopyTo(ref BlockF legacyBlock)
{
this.CopyTo(legacyBlock.Data);
@ -383,12 +405,15 @@ namespace ImageSharp.Formats
/// <summary>
/// Level shift by +128, clip to [0, 255], and write to buffer.
/// </summary>
/// <param name="buffer">Color buffer</param>
/// <param name="stride">Stride offset</param>
/// <param name="tempBlockPtr">Temp Block pointer</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal unsafe void CopyColorsTo(MutableSpan<byte> buffer, int stride, Block8x8F* temp)
internal unsafe void CopyColorsTo(MutableSpan<byte> buffer, int stride, Block8x8F* tempBlockPtr)
{
this.TransformByteConvetibleColorValuesInto(ref *temp);
this.TransformByteConvetibleColorValuesInto(ref *tempBlockPtr);
float* src = (float*)temp;
float* src = (float*)tempBlockPtr;
for (int i = 0; i < 8; i++)
{
buffer[0] = (byte)src[0];

5
src/ImageSharp/Formats/Jpg/Components/Bytes.cs

@ -38,6 +38,7 @@ namespace ImageSharp.Formats
/// <summary>
/// Creates a new instance of the <see cref="Bytes"/>, and initializes it's buffer.
/// </summary>
/// <returns>The bytes created</returns>
public static Bytes Create()
{
return new Bytes { Buffer = ArrayPool.Rent(4096) };
@ -56,6 +57,8 @@ namespace ImageSharp.Formats
/// <summary>
/// ReadByteStuffedByte is like ReadByte but is for byte-stuffed Huffman data.
/// </summary>
/// <param name="inputStream">Input stream</param>
/// <param name="errorCode">Error code</param>
/// <returns>The <see cref="byte"/></returns>
internal byte ReadByteStuffedByte(Stream inputStream, out JpegDecoderCore.ErrorCodes errorCode)
{
@ -112,6 +115,7 @@ namespace ImageSharp.Formats
/// <summary>
/// Returns the next byte, whether buffered or not buffered. It does not care about byte stuffing.
/// </summary>
/// <param name="inputStream">Input stream</param>
/// <returns>The <see cref="byte"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal byte ReadByte(Stream inputStream)
@ -131,6 +135,7 @@ namespace ImageSharp.Formats
/// Fills up the bytes buffer from the underlying stream.
/// It should only be called when there are no unread bytes in bytes.
/// </summary>
/// <param name="inputStream">Input stream</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void Fill(Stream inputStream)
{

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

@ -1874,7 +1874,7 @@ namespace ImageSharp.Formats
/// </summary>
/// <param name="b">The block of coefficients</param>
/// <param name="h">The Huffman tree</param>
/// <param name="unzigPtr"></param>
/// <param name="unzigPtr">Unzig ptr</param>
/// <param name="zigStart">The zig-zag start index</param>
/// <param name="zigEnd">The zig-zag end index</param>
/// <param name="delta">The low transform offset</param>

Loading…
Cancel
Save