<PackageReference Include="System.Drawing.Common" Version="9.0.1" />

BitmapData

public sealed class BitmapData
Specifies the attributes of a bitmap image. The BitmapData class is used by the LockBits and UnlockBits methods of the Bitmap class. Not inheritable.
using System.ComponentModel; using System.Runtime.InteropServices; namespace System.Drawing.Imaging { [StructLayout(LayoutKind.Sequential)] public sealed class BitmapData { private int _width; private int _height; private int _stride; private PixelFormat _pixelFormat; private IntPtr _scan0; private int _reserved; public int Width { get { return _width; } set { _width = value; } } public int Height { get { return _height; } set { _height = value; } } public int Stride { get { return _stride; } set { _stride = value; } } public PixelFormat PixelFormat { get { return _pixelFormat; } set { if (value <= PixelFormat.Format8bppIndexed) { if (value <= PixelFormat.Format16bppRgb565) { if (value <= PixelFormat.Max) { if (value != 0 && value != PixelFormat.Max) goto IL_010f; } else if (value != PixelFormat.Indexed && value != PixelFormat.Gdi && (uint)(value - 135173) > 1) { goto IL_010f; } goto IL_0125; } switch (value) { case PixelFormat.Format24bppRgb: case PixelFormat.Format32bppRgb: case PixelFormat.Format1bppIndexed: case PixelFormat.Format4bppIndexed: case PixelFormat.Format8bppIndexed: goto IL_0125; } } else { switch (value) { case PixelFormat.Alpha: case PixelFormat.Format16bppArgb1555: case PixelFormat.PAlpha: case PixelFormat.Format32bppPArgb: case PixelFormat.Extended: case PixelFormat.Format16bppGrayScale: case PixelFormat.Format48bppRgb: case PixelFormat.Format64bppPArgb: case PixelFormat.Canonical: case PixelFormat.Format32bppArgb: case PixelFormat.Format64bppArgb: goto IL_0125; } } goto IL_010f; IL_0125: _pixelFormat = value; return; IL_010f: throw new InvalidEnumArgumentException("value", (int)value, typeof(PixelFormat)); } } public IntPtr Scan0 { get { return _scan0; } set { _scan0 = value; } } public int Reserved { get { return _reserved; } set { _reserved = value; } } internal ref int GetPinnableReference() { return ref _width; } } }