Save images to memorystream?

  • Thread starter Thread starter Stupid48
  • Start date Start date
S

Stupid48

I'm writing a simple screen capture program that is using the Bitmap
class to save the capture. I would like to do multiple captures and
save them as we go along. I know that I could save them to a
temporary folder on the filesystem but is there a way to save them to
memory (i.e. memorystream) and, if so, how do I reference them later
(C# or VB.Net is fine)?

Thanks, Chris
 
Hello S,
You could use the Bitmap.Save method. The method supports both a filename
parameter and a Stream parameter. Check the overloads to see which one suits
you.
A quick example I just cooked up:
Bitmap bmp; // this is the captured image
System.IO.MemoryStream memStream = new MemoryStream();
bmp.Save( memStream, System.Drawing.Imaging.ImageFormat.MemoryBmp );
You could try other overloads of the Save method to suit your needs. I'm
also not very sure of the second parameter to the Save method; you'll have
to use the format which suits you the most.
 
Back
Top