ImageProcessor.Imaging.FastBitmap.SetPixel C# (CSharp) Метод

SetPixel() публичный Метод

Sets the color of the specified pixel of the System.Drawing.Bitmap.
public SetPixel ( int x, int y, Color color ) : void
x int The x-coordinate of the pixel to set.
y int The y-coordinate of the pixel to set.
color Color /// A color structure that represents the /// color to set the specified pixel. ///
Результат void
        public void SetPixel(int x, int y, Color color)
        {
            #if DEBUG
            if ((x < 0) || (x >= this.width))
            {
                throw new ArgumentOutOfRangeException("x", "Value cannot be less than zero or greater than the bitmap width.");
            }

            if ((y < 0) || (y >= this.height))
            {
                throw new ArgumentOutOfRangeException("y", "Value cannot be less than zero or greater than the bitmap height.");
            }
            #endif
            Color32* data = this[x, y];
            data->Argb = color.ToArgb();
        }

Usage Example

Пример #1
0
 public void ApplyFilter(FastBitmap image)
 {
     for (var i = 0; i < image.Height; ++i)
     {
         for (var j = 0; j < image.Width; ++j)
         {
             var pixel = image.GetPixel(j, i);
             if (pixel.R + pixel.G + pixel.B > 300)
             {
                 image.SetPixel(j, i, System.Drawing.Color.FromArgb(200, 255, 255));
             }
             else
             {
                 image.SetPixel(j, i, System.Drawing.Color.FromArgb(255, 0, 0, 30));
             }
         }
     }
 }
All Usage Examples Of ImageProcessor.Imaging.FastBitmap::SetPixel