Saving a bitmap into a MemoryStream

岁酱吖の 提交于 2019-12-03 09:34:19

.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 runtime when you've finished with memory by using Close() or Dispose(). The using statement can be used to wrap a resource such as MemoryStream to tell the runtime that the memory can be reclaimed.

You don't need to preallocate memory.

You can get the size afterwards with memoryStream.Length.


After you've done what you need to with your memoryStream, be sure to dispose it (or wrap it all in a using statement).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!