I get an error saying the encoder parameter is required on the Save() line at runtime. I have no idea what I should be putting for this parameter though. Any ideas?
using (Bitmap bmpScreenCapture = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height))
{
using (Graphics g = Graphics.FromImage(bmpScreenCapture))
{
g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y,
0, 0,
bmpScreenCapture.Size,
CopyPixelOperation.SourceCopy);
MemoryStream ms = new MemoryStream();
bmpScreenCapture.Save(ms, bmpScreenCapture.RawFormat); // <---- ERROR
byte[] bytes = ms.GetBuffer();
ms.Close();
}
}