File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -94,8 +94,50 @@ public TColor[] ToArray()
9494 return array ;
9595 }
9696
97+ /// <inheritdoc cref="System.Collections.IEnumerable.GetEnumerator"/>
98+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
99+ public Enumerator GetEnumerator ( ) => new ( _pixels ) ;
100+
97101 #endregion
98102
103+ public ref struct Enumerator
104+ {
105+ #region Properties & Fields
106+
107+ private readonly ReadOnlySpan < TColor > _pixels ;
108+ private int _position ;
109+
110+ /// <inheritdoc cref="System.Collections.Generic.IEnumerator{T}.Current"/>
111+ public TColor Current
112+ {
113+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
114+ get => _pixels [ _position ] ;
115+ }
116+
117+ #endregion
118+
119+ #region Constructors
120+
121+
122+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
123+ internal Enumerator ( ReadOnlySpan < TColor > pixels )
124+ {
125+ this . _pixels = pixels ;
126+
127+ _position = - 1 ;
128+ }
129+
130+ #endregion
131+
132+ #region Methods
133+
134+ /// <inheritdoc cref="System.Collections.IEnumerator.MoveNext"/>
135+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
136+ public bool MoveNext ( ) => ++ _position < _pixels . Length ;
137+
138+ #endregion
139+ }
140+
99141 #region Indexer-Structs
100142
101143 public readonly ref struct ImageRows
You can’t perform that action at this time.
0 commit comments