有人做过FLASH验证码识别吗?

图形验证码识别的资料满天飞,就是没见到有flash的.
有人做过吗?给个思路.
和图形识别没有根本区别,得到元素的IHTMLElementRender接口,调用DrawToDC画到你的Memory   DC上去。

private void OnDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
            WebBrowser browser = (sender as WebBrowser);

            if (browser != null) {
                mshtml.IHTMLDocument2 document = (browser.Document.DomDocument as mshtml.IHTMLDocument2);
                if (document != null) {
                    mshtml.IHTMLElement element = (document.body as mshtml.IHTMLElement);
                    if (element != null) {
                        IHTMLElementRender render = (element as IHTMLElementRender);
                        if (render != null) {
                            using (Graphics graphics = this.CreateGraphics()) {
                                IntPtr hdcDestination = graphics.GetHdc();
                                render.DrawToDC(hdcDestination);
                                IntPtr hdcMemory = GDI32.CreateCompatibleDC(hdcDestination);
                                IntPtr bitmap = GDI32.CreateCompatibleBitmap(
                                  hdcDestination,
                                  browser.ClientRectangle.Width,
                                  browser.ClientRectangle.Height
                                  );

                                if (bitmap != IntPtr.Zero) {
                                    IntPtr hOld = (IntPtr)GDI32.SelectObject(hdcMemory, bitmap);
                                    GDI32.BitBlt(
                                      hdcMemory,
                                      0, 0,
                                      browser.ClientRectangle.Width, browser.ClientRectangle.Height,
                                      hdcDestination,
                                      0, 0,
                                      TernaryRasterOperations.SRCCOPY
                                      );
                                    GDI32.SelectObject(hdcMemory, hOld);
                                    GDI32.DeleteDC(hdcMemory);
                                    graphics.ReleaseHdc(hdcDestination);

                                    SaveThumbnail(Image.FromHbitmap(bitmap));
                                }
                            }
                        }
                    }
                }
            }
        }
private void SaveThumbnail(Image image) {
            if (image != null) {//创建一个位图图像
                Bitmap thumbnail = new Bitmap(160, 120, PixelFormat.Format24bppRgb);
                thumbnail.SetResolution(image.HorizontalResolution, image.VerticalResolution);

                using (Graphics resize = Graphics.FromImage(thumbnail)) {
                    resize.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    resize.DrawImage(image,
                      new Rectangle(0, 0, 160, 120),
                      new Rectangle(0, 0, _webBrowser.ClientRectangle.Width, _webBrowser.ClientRectangle.Height),
                      GraphicsUnit.Pixel);
                }
                thumbnail.Save(_file.FullName, ImageFormat.Png);
            }
        }

转载于:https://www.cnblogs.com/renzhe/archive/2013/04/20/3032009.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值