c#抓屏功能在DPI缩放后,截到的图片不完整的问题

        /// <summary>
        /// 获取屏幕快照
        /// </summary>
        /// <returns></returns>
        public static Bitmap GetScreenSnapshot()
        {
            Bitmap bitmap = null;
            try
            {
                Graphics g = Graphics.FromHwnd(IntPtr.Zero);
                //100%的时候,DPI是96;这条语句的作用时获取放大比例
                float factor = g.DpiX / 96;
                Rectangle rc = new Rectangle(0, 0, (int)(SystemParameters.PrimaryScreenWidth * factor), (int)(SystemParameters.PrimaryScreenHeight * factor));
                bitmap = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb);
                using (Graphics memoryGrahics = Graphics.FromImage(bitmap))
                {
                    memoryGrahics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, CopyPixelOperation.SourceCopy);
                }
            }
            catch (Exception ex)
            {
                NlogHelper.Error("截屏失败", ex);
            }
            return bitmap;
        }
原文地址:https://www.cnblogs.com/xclw/p/6768870.html