Exemple #1
0
 /// <summary>Iterates through a set of <see cref="T:System.Drawing.Analysis.Manipulation.Pixel"/>s and sets the <see cref="T:System.Drawing.Analysis.NativeColor"/> using a given <see cref="T:System.Drawing.Analysis.ISetPixelProvider"/>.</summary>
 /// <param name="source">The source.</param>
 /// <param name="color">The <see cref="T:System.Drawing.Analysis.NativeColor"/> to set the <see cref="T:System.Drawing.Analysis.Manipulation.Pixel"/> to.</param>
 /// <param name="provider">The <see cref="T:System.Drawing.Analysis.ISetPixelProvider"/> that will be used to perform the SetPixel operation.</param>
 /// <returns>An <see cref="T:System.Collections.Generic.IEnumerable{Pixel}"/> with the new colors set.</returns>
 public static IEnumerable<Pixel> SetColor(this IEnumerable<Pixel> source, NativeColor color, ISetPixelProvider provider)
 {
     if (provider == null)
         throw new ArgumentNullException("provider");
     foreach (var item in source)
     {
         provider.SetPixel(item.X, item.Y, color);
         yield return new Pixel(item.X, item.Y, color);
     }
 }
Exemple #2
0
 /// <summary>Copies the entire pixel data to another provider.</summary>
 /// <param name="destination">The destination pixel provider.</param>
 public virtual void CopyTo(ISetPixelProvider destination)
 {
     if (destination == null)
         throw new ArgumentNullException("destination");
     if (Size != destination.Size)
         throw new InvalidOperationException("The sizes of the providers must be equal");
     int x, y;
     NativeColor c;
     for (y = 0; y < Size.Height; ++y)
         for (x = 0; x < Size.Width; ++x)
         {
             c = GetPixel(x, y);
             destination.SetPixel(x, y, c);
         }
 }