, , , BitmapData.Stride:
- ( ), . , . , .
, , :
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat);
Marshal.Copy(myByteArray, 0, bmpData.Scan0 +
( bmpData.Stride >= 0 ? 0 : bmpData.Stride*(bmp.Height-1) ),
myByteArray.Length);
: : new Bitmap(Width, Height, PixelFormat.Format24bppRgb);... ?
ILSpy:
public Bitmap(int width, int height, PixelFormat format)
{
IntPtr zero = IntPtr.Zero;
int num = SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0(width, height, 0, (int)format, NativeMethods.NullHandleRef, out zero);
if (num != 0)
{
throw SafeNativeMethods.Gdip.StatusException(num);
}
base.SetNativeImage(zero);
}
[DllImport("gdiplus.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
internal static extern int GdipCreateBitmapFromScan0(int width, int height, int stride, int format, HandleRef scan0, out IntPtr bitmap);
:
Bitmap(
[in] INT width,
[in] INT height,
[in] INT stride,
[in] PixelFormat format,
[in] BYTE *scan0
);
[in]
: INT
Integer, . ( ) (, 2 16 ), . , .
0? , . -? ? ( .NET new Bitmap(Width, Height, PixelFormat.Format24bppRgb)). BitmapData.Stride.