zoukankan      html  css  js  c++  java
  • 有人做过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);
                }
            }
  • 相关阅读:
    SEO高手和SEO屌丝的八个区
    【织梦免费模板】防火涂料网站模版
    利用火车头采集A67手机电影教程一
    SEO高级技巧
    .NET代码设计简单规范
    JAVA 和.NET在安全功能的比较
    poi实现excel数据的导入和导出
    eclipse复制bpmn文件到idea下乱码问题处理
    分账接收方与原请求方不一致,微信分账总结
    Java List<T> 去重
  • 原文地址:https://www.cnblogs.com/renzhe/p/3032009.html
Copyright © 2011-2022 走看看