GDI+ generic error saving bitmap created from memory using LockBits
问题 The GDI+ generic error when saving a bitmap is obviously a common problem according to my research here on SO and the web. Given following simplified snippet: byte[] bytes = new byte[2048 * 2048 * 2]; for (int i = 0; i < bytes.Length; i++) { // set random or constant pixel data, whatever you want } Bitmap bmp = new Bitmap(2048, 2048, PixelFormat.Format16bppGrayScale); BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, 2048, 2048), ImageLockMode.ReadWrite, bmp.PixelFormat); System.Runtime