当我从窗口放大设置,它永远不会捕获确切的桌面屏幕。它只会放大位图并显示给我们看。

怎样才能在放大窗口后得到原图。
这里是代码:-
private static BitmapSource CopyScreen()
{
BitmapSource BS = null;
int screenLeft = SystemInformation.VirtualScreen.Left;
int screenTop = SystemInformation.VirtualScreen.Top;
int screenWidth = SystemInformation.VirtualScreen.Width;
int screenHeight = SystemInformation.VirtualScreen.Height;
using (Bitmap screenBmp = new Bitmap(screenWidth, screenHeight))
{
using (Graphics bmpGraphics = Graphics.FromImage(screenBmp))
{
bmpGraphics.CopyFromScreen(screenLeft, screenTop, 0, 0, screenBmp.Size);
BS = Imaging.CreateBitmapSourceFromHBitmap(screenBmp.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
}
}
return BS;
}从上面的代码我得到放大的图片。

我想要的:-这是原来显示的图片,不是放大的图片(只是显示在我的桌面上的显示器)。

我想捕捉桌面的屏幕,但屏幕的界限没有得到正确的同时放大窗口。能不能用它的实际分辨率来捕捉屏幕截图而不是放大.It捕捉右上角的屏幕
发布于 2018-06-06 10:44:23
这是因为CreateBitmapSourceFromHBitmap中的调整选项。
但是,如果您只需要制作截图,就不需要它了,因为您可以按如下方式使用位图:
Bitmap screenshot = new Bitmap(
SystemInformation.VirtualScreen.Width,
SystemInformation.VirtualScreen.Height,
PixelFormat.Format32bppArgb);
using (Graphics screenGraph = Graphics.FromImage(screenshot))
{
screenGraph.CopyFromScreen(
SystemInformation.VirtualScreen.X,
SystemInformation.VirtualScreen.Y,
0,
0,
SystemInformation.VirtualScreen.Size,
CopyPixelOperation.SourceCopy);
}
screenshot.Save("screenshot.png");如果您确实需要位映射源,则可以使用任意格式的MemoryStream。
https://stackoverflow.com/questions/50718064
复制相似问题