Utilities.Media.SwiftBitmap.GetPixel C# (CSharp) Method

GetPixel() public method

Gets the pixel.
public GetPixel ( int position ) : Color
position int The position in the image
return Color
        public unsafe Color GetPixel(int position)
        {
            Contract.Requires<NullReferenceException>(Data != null);
            byte* TempPointer = DataPointer + (position * PixelSize);
            return (PixelSize == 3) ?
                Color.FromArgb(TempPointer[2], TempPointer[1], TempPointer[0]) :
                Color.FromArgb(TempPointer[3], TempPointer[2], TempPointer[1], TempPointer[0]);
        }

Same methods

SwiftBitmap::GetPixel ( int x, int y ) : Color

Usage Example

 /// <summary>
 /// Loads an image
 /// </summary>
 /// <param name="ImageUsing">Image to load</param>
 public virtual void LoadImage(SwiftBitmap ImageUsing)
 {
     Contract.Requires <ArgumentNullException>(ImageUsing != null, "ImageUsing");
     Width  = ImageUsing.Width;
     Height = ImageUsing.Height;
     ImageUsing.Lock();
     R.Clear();
     G.Clear();
     B.Clear();
     for (int x = 0; x < ImageUsing.Width; ++x)
     {
         for (int y = 0; y < ImageUsing.Height; ++y)
         {
             var TempColor = ImageUsing.GetPixel(x, y);
             ++R[(int)TempColor.R];
             ++G[(int)TempColor.G];
             ++B[(int)TempColor.B];
         }
     }
     ImageUsing.Unlock();
 }
All Usage Examples Of Utilities.Media.SwiftBitmap::GetPixel