问题应该是解决了感觉是屏幕拷贝的时候会出现白点,在用矩形框进行绘制的时候也带上了白点
这是之前的代码:
/// <summary> /// 得到屏幕拷贝 /// </summary> /// <returns></returns> private Bitmap GetScreenImage() { Rectangle r = Screen.PrimaryScreen.Bounds; Bitmap img = new Bitmap(r.Width, r.Height); Graphics g = Graphics.FromImage(img); g.CopyFromScreen(new Point(0, 0), new Point(0, 0), r.Size); g.Dispose(); return img; } private void SaveCutImage() { Bitmap _iamge = GetScreenImage(); Rectangle _rc = new Rectangle(rc.X + 5, rc.Y + 5, rc.Width - 10, rc.Height - 10); bitImage = new Bitmap(_rc.Width, _rc.Height); Graphics g = Graphics.FromImage(bitImage); g.SmoothingMode = SmoothingMode.HighQuality; g.DrawImage(_iamge, new Rectangle(0, 0, _rc.Width, _rc.Height), _rc.Left, _rc.Top, _rc.Width, _rc.Height, GraphicsUnit.Pixel); g.Dispose(); }
这是改进之后的,虽然有白点,但是截出的图片中没有白点
1 /// <summary> 2 /// 得到屏幕拷贝 3 /// </summary> 4 /// <returns></returns> 5 private Bitmap GetScreenImage() 6 { 7 Bitmap bkImage = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height); 8 Graphics g = Graphics.FromImage(bkImage); 9 g.CopyFromScreen(new Point(0, 0), new Point(0, 0), Screen.AllScreens[0].Bounds.Size, CopyPixelOperation.SourceCopy); 10 screenImage = (Bitmap)bkImage.Clone();//个人感觉这句话 11 g.FillRectangle(new SolidBrush(Color.FromArgb(60, Color.Gray)), Screen.PrimaryScreen.Bounds); 12 return bkImage; 13 } 14 private void SaveCutImage() 15 { 16 if (rc.Width > 0 && rc.Height > 0) 17 { 18 Bitmap _iamge = new Bitmap(screenImage,this.Width,this.Height); 19 //Bitmap _iamge = GetScreenImage(); 20 Rectangle _rc = new Rectangle(rc.X + 5, rc.Y + 5, rc.Width - 10, rc.Height - 10); 21 bitImage = new Bitmap(_rc.Width, _rc.Height); 22 Graphics g = Graphics.FromImage(bitImage); 23 g.SmoothingMode = SmoothingMode.HighQuality; 24 g.DrawImage(_iamge, new Rectangle(0, 0, _rc.Width, _rc.Height), _rc.Left, _rc.Top, _rc.Width, _rc.Height, GraphicsUnit.Pixel); 25 g.Dispose(); 26 this.Close(); 27 } 28 }
个人感觉加黄的两句话起到了作用,通过拷贝屏幕拷贝的对象。这个ScreenImage应该是没有白点的。
没事