I'm trying to capture MEmu emulator screen using some win apis, but everything I tried I keep getting a black screen, the screenshot has the correct size, but it's all black.
Here is some code I'm using now:
IntPtr hwnd = Process.GetProcessByName("Memu")[0].MainWindowHandle; //Gets the first process
RECT2 rc;
GetWindowRect(hwnd, out rc);
Bitmap bmp = new Bitmap(rc.Width, rc.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Graphics gfxBmp = Graphics.FromImage(bmp);
IntPtr hdcBitmap = gfxBmp.GetHdc();
PrintWindow(hwnd, hdcBitmap, 1);
gfxBmp.ReleaseHdc(hdcBitmap);
gfxBmp.Dispose();
bmp.Save("test.png");
Looks like the android runs in a virtual machine (probably virtual Box), not sure if that's the problem and if there is a way to capture virtual screens like this.
It looks like you are capturing the screen using the BMP file format. Try saving the image as a .bmp instead of .png, since you are classifying it as a BMP in your code.
Try this:
IntPtr hwnd = Process.GetProcessByName("Memu")[0].MainWindowHandle; //Gets the first process
RECT2 rc;
GetWindowRect(hwnd, out rc);
Bitmap bmp = new Bitmap(rc.Width, rc.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Graphics gfxBmp = Graphics.FromImage(bmp);
IntPtr hdcBitmap = gfxBmp.GetHdc();
PrintWindow(hwnd, hdcBitmap, 1);
gfxBmp.ReleaseHdc(hdcBitmap);
gfxBmp.Dispose();
bmp.Save("test.bmp");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.