mirror of
https://github.com/DarthAffe/HPPH.git
synced 2025-12-12 13:28:37 +00:00
Added some of the missing doc-comments
This commit is contained in:
parent
9f3fbc7473
commit
db218e0e8d
@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
|
|||||||
|
|
||||||
namespace HPPH;
|
namespace HPPH;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc cref="IImage{T}" />
|
||||||
[SkipLocalsInit]
|
[SkipLocalsInit]
|
||||||
public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
||||||
where T : struct, IColor
|
where T : struct, IColor
|
||||||
@ -37,6 +37,7 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
|
|
||||||
#region Indexer
|
#region Indexer
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
IColor IImage.this[int x, int y] => this[x, y];
|
IColor IImage.this[int x, int y] => this[x, y];
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -51,6 +52,7 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
IImage IImage.this[int x, int y, int width, int height]
|
IImage IImage.this[int x, int y, int width, int height]
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -74,6 +76,7 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
IImageRows IImage.Rows => new IColorImageRows<T>(_buffer, _x, _y, Width, Height, _stride);
|
IImageRows IImage.Rows => new IColorImageRows<T>(_buffer, _x, _y, Width, Height, _stride);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -122,6 +125,7 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
return new Image<T>(data, 0, 0, width, height, stride);
|
return new Image<T>(data, 0, 0, width, height, stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public IImage<TColor> ConvertTo<TColor>()
|
public IImage<TColor> ConvertTo<TColor>()
|
||||||
where TColor : struct, IColor
|
where TColor : struct, IColor
|
||||||
{
|
{
|
||||||
@ -141,6 +145,7 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void CopyTo(Span<T> destination) => CopyTo(MemoryMarshal.AsBytes(destination));
|
public void CopyTo(Span<T> destination) => CopyTo(MemoryMarshal.AsBytes(destination));
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -167,6 +172,7 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public T[] ToArray()
|
public T[] ToArray()
|
||||||
{
|
{
|
||||||
T[] colors = new T[Width * Height];
|
T[] colors = new T[Width * Height];
|
||||||
@ -175,6 +181,7 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO DarthAffe 11.07.2024: This has some potential for optimization
|
//TODO DarthAffe 11.07.2024: This has some potential for optimization
|
||||||
|
/// <inheritdoc />
|
||||||
IColor[] IImage.ToArray()
|
IColor[] IImage.ToArray()
|
||||||
{
|
{
|
||||||
IColor[] colors = new IColor[Width * Height];
|
IColor[] colors = new IColor[Width * Height];
|
||||||
@ -187,8 +194,10 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
return colors;
|
return colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public RefImage<T> AsRefImage() => new(_buffer, _x, _y, Width, Height, _stride);
|
public RefImage<T> AsRefImage() => new(_buffer, _x, _y, Width, Height, _stride);
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public RefImage<TColor> AsRefImage<TColor>()
|
public RefImage<TColor> AsRefImage<TColor>()
|
||||||
where TColor : struct, IColor
|
where TColor : struct, IColor
|
||||||
{
|
{
|
||||||
@ -208,6 +217,7 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
return ref Unsafe.Add(ref MemoryMarshal.GetReference(_buffer.AsSpan()), (_y * _stride) + (_x * ColorFormat.BytesPerPixel));
|
return ref Unsafe.Add(ref MemoryMarshal.GetReference(_buffer.AsSpan()), (_y * _stride) + (_x * ColorFormat.BytesPerPixel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public IEnumerator<T> GetEnumerator()
|
public IEnumerator<T> GetEnumerator()
|
||||||
{
|
{
|
||||||
for (int y = 0; y < Height; y++)
|
for (int y = 0; y < Height; y++)
|
||||||
@ -215,6 +225,7 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
yield return this[x, y];
|
yield return this[x, y];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
IEnumerator<IColor> IEnumerable<IColor>.GetEnumerator()
|
IEnumerator<IColor> IEnumerable<IColor>.GetEnumerator()
|
||||||
{
|
{
|
||||||
for (int y = 0; y < Height; y++)
|
for (int y = 0; y < Height; y++)
|
||||||
@ -222,9 +233,11 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
yield return this[x, y];
|
yield return this[x, y];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||||
|
|
||||||
//TODO DarthAffe 20.07.2024: All of those equals can be optimized
|
//TODO DarthAffe 20.07.2024: All of those equals can be optimized
|
||||||
|
/// <inheritdoc />
|
||||||
public bool Equals(IImage? other)
|
public bool Equals(IImage? other)
|
||||||
{
|
{
|
||||||
if (other == null) return false;
|
if (other == null) return false;
|
||||||
@ -240,6 +253,7 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public bool Equals(IImage<T>? other)
|
public bool Equals(IImage<T>? other)
|
||||||
{
|
{
|
||||||
if (other == null) return false;
|
if (other == null) return false;
|
||||||
@ -254,6 +268,7 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public bool Equals(Image<T>? other)
|
public bool Equals(Image<T>? other)
|
||||||
{
|
{
|
||||||
if (other == null) return false;
|
if (other == null) return false;
|
||||||
@ -268,5 +283,11 @@ public sealed class Image<T> : IImage<T>, IEquatable<Image<T>>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override bool Equals(object? obj) => Equals(obj as Image<T>);
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override int GetHashCode() => HashCode.Combine(ColorFormat, Width, Height, _buffer.GetHashCode());
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -124,14 +124,17 @@ internal class IColorImageColumn<T> : IImageColumn
|
|||||||
private readonly int _length;
|
private readonly int _length;
|
||||||
private readonly int _step;
|
private readonly int _step;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public int Length => _length;
|
public int Length => _length;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public int SizeInBytes => Length * T.ColorFormat.BytesPerPixel;
|
public int SizeInBytes => Length * T.ColorFormat.BytesPerPixel;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Indexer
|
#region Indexer
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public IColor this[int y]
|
public IColor this[int y]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -158,6 +161,7 @@ internal class IColorImageColumn<T> : IImageColumn
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void CopyTo(Span<IColor> destination)
|
public void CopyTo(Span<IColor> destination)
|
||||||
{
|
{
|
||||||
if (destination == null) throw new ArgumentNullException(nameof(destination));
|
if (destination == null) throw new ArgumentNullException(nameof(destination));
|
||||||
@ -167,6 +171,7 @@ internal class IColorImageColumn<T> : IImageColumn
|
|||||||
destination[i] = this[i];
|
destination[i] = this[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void CopyTo(Span<byte> destination)
|
public void CopyTo(Span<byte> destination)
|
||||||
{
|
{
|
||||||
if (destination == null) throw new ArgumentNullException(nameof(destination));
|
if (destination == null) throw new ArgumentNullException(nameof(destination));
|
||||||
@ -178,6 +183,7 @@ internal class IColorImageColumn<T> : IImageColumn
|
|||||||
target[i] = Unsafe.As<byte, T>(ref Unsafe.Add(ref dataRef, i * _step));
|
target[i] = Unsafe.As<byte, T>(ref Unsafe.Add(ref dataRef, i * _step));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public IColor[] ToArray()
|
public IColor[] ToArray()
|
||||||
{
|
{
|
||||||
IColor[] array = new IColor[Length];
|
IColor[] array = new IColor[Length];
|
||||||
@ -185,12 +191,14 @@ internal class IColorImageColumn<T> : IImageColumn
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public IEnumerator<IColor> GetEnumerator()
|
public IEnumerator<IColor> GetEnumerator()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Length; i++)
|
for (int i = 0; i < Length; i++)
|
||||||
yield return this[i];
|
yield return this[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -113,12 +113,14 @@ internal class IColorImageColumns<T> : IImageColumns
|
|||||||
private readonly int _stride;
|
private readonly int _stride;
|
||||||
private readonly int _bpp;
|
private readonly int _bpp;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public int Count => _width;
|
public int Count => _width;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Indexer
|
#region Indexer
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public IImageColumn this[int column]
|
public IImageColumn this[int column]
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -151,12 +153,14 @@ internal class IColorImageColumns<T> : IImageColumns
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public IEnumerator<IImageColumn> GetEnumerator()
|
public IEnumerator<IImageColumn> GetEnumerator()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _width; i++)
|
for (int i = 0; i < _width; i++)
|
||||||
yield return this[i];
|
yield return this[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -117,14 +117,17 @@ internal class IColorImageRow<T> : IImageRow
|
|||||||
private readonly int _start;
|
private readonly int _start;
|
||||||
private readonly int _length;
|
private readonly int _length;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public int Length => _length;
|
public int Length => _length;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public int SizeInBytes => Length * T.ColorFormat.BytesPerPixel;
|
public int SizeInBytes => Length * T.ColorFormat.BytesPerPixel;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Indexer
|
#region Indexer
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public IColor this[int x]
|
public IColor this[int x]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -150,6 +153,7 @@ internal class IColorImageRow<T> : IImageRow
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void CopyTo(Span<IColor> destination)
|
public void CopyTo(Span<IColor> destination)
|
||||||
{
|
{
|
||||||
if (destination == null) throw new ArgumentNullException(nameof(destination));
|
if (destination == null) throw new ArgumentNullException(nameof(destination));
|
||||||
@ -159,6 +163,7 @@ internal class IColorImageRow<T> : IImageRow
|
|||||||
destination[i] = this[i];
|
destination[i] = this[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void CopyTo(Span<byte> destination)
|
public void CopyTo(Span<byte> destination)
|
||||||
{
|
{
|
||||||
if (destination == null) throw new ArgumentNullException(nameof(destination));
|
if (destination == null) throw new ArgumentNullException(nameof(destination));
|
||||||
@ -167,6 +172,7 @@ internal class IColorImageRow<T> : IImageRow
|
|||||||
_buffer.AsSpan().Slice(_start, SizeInBytes).CopyTo(destination);
|
_buffer.AsSpan().Slice(_start, SizeInBytes).CopyTo(destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public IColor[] ToArray()
|
public IColor[] ToArray()
|
||||||
{
|
{
|
||||||
IColor[] array = new IColor[Length];
|
IColor[] array = new IColor[Length];
|
||||||
@ -174,12 +180,14 @@ internal class IColorImageRow<T> : IImageRow
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public IEnumerator<IColor> GetEnumerator()
|
public IEnumerator<IColor> GetEnumerator()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _length; i++)
|
for (int i = 0; i < _length; i++)
|
||||||
yield return this[i];
|
yield return this[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -111,12 +111,14 @@ internal class IColorImageRows<T> : IImageRows
|
|||||||
private readonly int _height;
|
private readonly int _height;
|
||||||
private readonly int _stride;
|
private readonly int _stride;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public int Count => _height;
|
public int Count => _height;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Indexer
|
#region Indexer
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public IImageRow this[int row]
|
public IImageRow this[int row]
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -147,12 +149,14 @@ internal class IColorImageRows<T> : IImageRows
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public IEnumerator<IImageRow> GetEnumerator()
|
public IEnumerator<IImageRow> GetEnumerator()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _height; i++)
|
for (int i = 0; i < _height; i++)
|
||||||
yield return this[i];
|
yield return this[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user