Saving a bitmap into a MemoryStream

后端 未结 2 639
感情败类
感情败类 2021-02-12 01:43

Should I allocate the memory or just the object of the memory stream: Is this OK?

MemoryStream memoryStream = new MemoryStream();
bitmap.Save(memoryStream, Syste         


        
2条回答
  •  野的像风
    2021-02-12 02:13

    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).

提交回复
热议问题