Saving a bitmap into a MemoryStream
问题 Should I allocate the memory or just the object of the memory stream: Is this OK? MemoryStream memoryStream = new MemoryStream(); bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); If I need to define the MemoryStream size, how can I get it from Bitmap? 回答1: .NET is a managed environment: specifically, memory allocation is usually managed on your behalf by the .NET runtime. You don't typically need to allocate the memory yourself. Sometimes, however, you do need to inform the