Reputation: 2151
I have a graphics library from a third party that has a method which creates a bitmap inside a folder. I want this method to write to a Drawing.Bitmap object instead of a physical file. Can I do this in .net
I am using C# 1.1
thanks.
Upvotes: 0
Views: 121
Reputation: 116987
I guess it depends on what the third party library allows. If you can get the bytes in memory instead of dumping them to a file, then yes, you can do this.
System.Drawing.Bitmap has several constructors that take a Stream, so you could create it from a MemoryStream. Something like this (rough, untested:)
byte[] imgBytes = thirdPartyLibrary.GetImage();
System.IO.MemoryStream stream = new System.IO.MemoryStream(imgBytes);
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(stream);
Upvotes: 1