I'm using the code below to capture the screen with a game running
public static Bitmap CaptureScreen()
{
DxScreenCapture cap = new DxScreenCapture();
var surface = cap.CaptureScreen();
Bitmap png;
using (DataStream stream = Surface.ToStream(surface, ImageFileFormat.Bmp))
{
png = new Bitmap(stream);
png.Save(@"C:\Temp\MyFile.bmp");
}
return png;
}
When saving as ImageFileFormat.Bmp
, the saved file is entirely black. If I change the format to ImageFileFormat.Png
(and the file extension to .png), the image saves just fine.
Why can I save in PNG format, but not in BMP format?
This code should work (see the complete enum):
png.Save(@"C:\Temp\MyFile.bmp", ImageFormat.Bmp)