当前位置: 首页 > news >正文

湖南住房和城乡建设部网站wordpress注册栏

湖南住房和城乡建设部网站,wordpress注册栏,做一个网站的全部流程,惠州市博罗县建设局网站在Windows登录界面进行截图#xff0c;目前尝试到的以下的截图方法可以截取到图#xff0c;其它的方式要么卡住#xff0c;要么截出来是黑屏的#xff0c;直接上代码#xff1a; /// summary使用Graphics方式捕获桌面截图(效率低于DesktopCapture#xff0c;主要…在Windows登录界面进行截图目前尝试到的以下的截图方法可以截取到图其它的方式要么卡住要么截出来是黑屏的直接上代码 /// summary使用Graphics方式捕获桌面截图(效率低于DesktopCapture主要用户登录界面截图)/summaryinternal class GraphicCapture{private const int Desktopvertres 117;private const int Desktophorzres 118;/// summary当前最新一帧/summaryprivate Bitmap _currentFrame;private Rectangle _currentScreenBounds;private Graphics _graphic;private readonly object _screenLock new object();private Bitmap _originBitmap;private bool _isManualCaptureStop;private PixelFormat _pixelFormat PixelFormat.Bgra32;private Size DesktopSize{get{IntPtr dc GraphicCapture.GetDC(IntPtr.Zero);int deviceCaps1 GraphicCapture.GetDeviceCaps(dc, 117);int deviceCaps2 GraphicCapture.GetDeviceCaps(dc, 118);GraphicCapture.ReleaseDC(IntPtr.Zero, dc);return new Size(deviceCaps2, deviceCaps1);}}[DllImport(user32.dll)]private static extern IntPtr GetDC(IntPtr ptr);[DllImport(gdi32.dll)]private static extern int GetDeviceCaps(IntPtr hdc, int nIndex);[DllImport(User32.dll)]private static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);/// summary构造函数/summarypublic GraphicCapture(){this._currentScreenBounds this.GetScreenRectangle(Screen.PrimaryScreen);this._originBitmap this.CreateBitmap();this._graphic Graphics.FromImage((Image) this._originBitmap);}private Rectangle GetScreenRectangle(Screen screen){Rectangle bounds screen.Bounds;return new Rectangle(new Point(bounds.X, bounds.Y), this.DesktopSize);}/// summaryBitmap转byte[]/summary/// param namebitmap/param/// returns/returnsprivate byte[] BitmapToByteArray(Bitmap bitmap){System.Drawing.Imaging.PixelFormat format this.PixelFormatConverter(this.PixelFormat);Rectangle rect new Rectangle(0, 0, bitmap.Width, bitmap.Height);BitmapData bitmapdata bitmap.LockBits(rect, ImageLockMode.ReadOnly, format);int length Math.Abs(bitmapdata.Stride) * bitmap.Height;byte[] destination new byte[length];Marshal.Copy(bitmapdata.Scan0, destination, 0, length);bitmap.UnlockBits(bitmapdata);return destination;}private Bitmap CreateBitmap(){System.Drawing.Imaging.PixelFormat pixelFormat this.PixelFormatConverter(this.PixelFormat);Size desktopSize this.DesktopSize;int width desktopSize.Width;desktopSize this.DesktopSize;int height desktopSize.Height;int format (int) pixelFormat;return new Bitmap(width, height, (System.Drawing.Imaging.PixelFormat) format);}private System.Drawing.Imaging.PixelFormat PixelFormatConverter(PixelFormat customPixelFormat){if (true);System.Drawing.Imaging.PixelFormat pixelFormat;if (customPixelFormat ! PixelFormat.Bgra32){if (customPixelFormat ! PixelFormat.Bgr24)throw new ArgumentOutOfRangeException(PixelFormat, (object) this.PixelFormat, (string) null);pixelFormat System.Drawing.Imaging.PixelFormat.Format24bppRgb;}elsepixelFormat System.Drawing.Imaging.PixelFormat.Format32bppArgb;if (true);return pixelFormat;}/// summary检索最新的桌面图像和关联的元数据/summaryprivate byte[] GetLatestFrameToByte() this.BitmapToByteArray(this.GetLatestFrameToBitmap());/// summary检索最新的桌面图像/summary/// returns/returnsprivate Bitmap GetLatestFrameToBitmap(){lock (this._screenLock){Graphics graphic this._graphic;int x this._currentScreenBounds.X;int y this._currentScreenBounds.Y;Size desktopSize this.DesktopSize;int width1 desktopSize.Width;desktopSize this.DesktopSize;int height1 desktopSize.Height;Size blockRegionSize new Size(width1, height1);graphic.CopyFromScreen(x, y, 0, 0, blockRegionSize);Size newSize;ref Size local ref newSize;desktopSize this.DesktopSize;int width2 (int) ((double) desktopSize.Width * this.Scale);desktopSize this.DesktopSize;int height2 (int) ((double) desktopSize.Height * this.Scale);local new Size(width2, height2);this._currentFrame newSize.Width this._originBitmap.Width newSize.Height this._originBitmap.Height ? this._originBitmap : new Bitmap((Image) this._originBitmap, newSize);}return this._currentFrame;}/// summary捕获图像像素格式默认为BGRA32/summarypublic PixelFormat PixelFormat{get this._pixelFormat;set{this._pixelFormat value;this._originBitmap?.Dispose();this._graphic?.Dispose();this._originBitmap this.CreateBitmap();this._graphic Graphics.FromImage((Image) this._originBitmap);}}/// summary捕获图像缩放大小默认为1.0/summarypublic double Scale { get; set; } 1.0;/// summary新帧捕获事件/summarypublic event EventHandlerCaptureFrame FrameArrived;/// summary开始捕获/summarypublic void StartCapture(){this._isManualCaptureStop false;}/// summary停止捕获/summarypublic void StopCapture(){this._cancellationTokenSource?.Cancel();this._isManualCaptureStop true;}/// summary获取下一帧图像数据/summary/// param namecaptureFrame/param/// returns/returnspublic bool TryGetNextFrame(out CaptureFrame captureFrame){captureFrame (CaptureFrame) null;if (this._isManualCaptureStop)return false;try{byte[] byteArray this.BitmapToByteArray(this.GetLatestFrameToBitmap());Size size new Size((int) ((double) this.DesktopSize.Width * this.Scale), (int) ((double) this.DesktopSize.Height * this.Scale));captureFrame new CaptureFrame(size, this.PixelFormat, byteArray);return true;}catch (Exception ex){return false;}}}操作鼠标键盘等操作可以参考本人另一篇文章使用C#制作可以录制自动化执行Windows操作脚本工具——类似于按键精灵 - log9527 - 博客园 (cnblogs.com)
http://www.huolong8.cn/news/255550/

相关文章:

  • 免费网站如何被百度收录邯郸网站设计培训机构
  • 建设部造价工程师网站宁波网络公司哪家好
  • 焦作做网站哪家好网站设计前景怎样
  • 钓鱼网站制作者网站源码程序
  • 做网站的人是什么职位个人怎么做ipv6的网站
  • 网站转化路径全球速卖通的特点
  • 河南外贸网站建设亅新厦建设集团网站
  • 销售网站排名wordpress 取消标签
  • wap网站建设流程查网站备案名称
  • 企业名称查重宁波seo排名费用
  • 百度网站关键词云服务器做网站难吗
  • 静态网站flash网站创建过程
  • 电子政务服务网站建设网站域名免费
  • 中国空间站结构示意图wordpress浏览器标签插件
  • 东营网站建设报价西安网站制作公司
  • 开发一个卖东西的网站多少网站 后台 安装
  • 邯郸哪有做网站的施工企业现状
  • 网站优化策略分析论文做网站收款支付宝接口
  • 南阳网站开发公司基本网站建设技术
  • 京伦科技做的网站如何好的seo
  • 做冲压件加工有什么好网站建设公司官方网站首页
  • 网站为什么要ipc备案大型回合制手游排行榜
  • 网站建设与维护课程总结代理猫
  • 网站开发的目的意义wordpress视频云解析
  • 重庆做网站建设的公司哪家好百度贴吧网页版入口
  • 免费代理上网网站定制软件开发文案
  • 如何恢复网站首页的排名 站长网页导航栏设计图片
  • 做网站要不要用控件电器网站建设免费咨询
  • php企业网站开发好学么贵阳网络推广优化
  • 长春网站建设网站源码地税局内网网站建设