【问题标题】:Capturing MEmu emulator screen捕捉逍遥模拟器画面
【发布时间】:2016-08-03 14:52:03
【问题描述】:

我正在尝试使用一些 win api 捕获 MEmu 模拟器屏幕,但我尝试的所有操作都一直黑屏,屏幕截图大小正确,但全黑。

这是我现在正在使用的一些代码:

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");

这是输出图像:

看起来 android 在虚拟机(可能是虚拟 Box)中运行,不确定是否是问题所在,是否有办法捕获这样的虚拟屏幕。

【问题讨论】:

    标签: c# android


    【解决方案1】:

    看起来您正在使用 BMP 文件格式捕获屏幕。尝试将图像保存为 .bmp 而不是 .png,因为您在代码中将其分类为 BMP。

    试试这个:

        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");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-16
      • 1970-01-01
      • 2014-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多