public static Rectangle Truncate(RectangleF value) => new Rectangle( (int)value.X, (int)value.Y, (int)value.Width, (int)value.Height);
/// <summary> /// Initializes the BitmapPixels class with a source Bitmap. /// </summary> /// <param name="source">The source Bitmap to load the pixels from.</param> public BitmapPixels(Bitmap source) { if (source == null) { throw new ArgumentNullException("source"); } PixelFormat format = source.PixelFormat; if (!ValidPixelFormat(format)) { throw new InvalidPixelFormatException(format); } GraphicsUnit unit = GraphicsUnit.Pixel; bitmapOwner = false; bitmap = source; bounds = Rectangle.Truncate(bitmap.GetBounds(ref unit)); }