protected override void OnDownloadImageFinished(string imageUrl, int httpStatusCode, CefImage image) { System.Console.WriteLine("Entering OnDownloadImageFinished"); int width; int height; CefBinaryValue cbv = image.GetAsPng(1, true, out width, out height); byte[] ba = cbv.ToArray(); System.Console.WriteLine("Exiting OnDownloadImageFinished"); }
protected override void OnDownloadImageFinished(string imageUrl, int httpStatusCode, CefImage image) { int imageW, imageH; if (itemNumber >= 0) { if (image == null || image.Width == 0) { MainForm.Instance.faTabStrip1.Items[itemNumber].ItemIcon = Resources.blank; MainForm.Instance.faTabStrip1.Items[itemNumber].BrowserIsLoading = false; MainForm.Instance.faTabStrip1.Invalidate(); } else { try { if (((CefWebBrowser)(MainForm.Instance.faTabStrip1.Items[itemNumber].splic.Panel1.Controls[0])).Browser != null)//.Title.Contains("加载中...")!=true) { MainForm.Instance.faTabStrip1.Items[itemNumber].ItemIcon = BytesToImage(image.GetAsPng(1f, true, out imageW, out imageH).ToArray()); MainForm.Instance.faTabStrip1.Items[itemNumber].BrowserIsLoading = false; MainForm.Instance.faTabStrip1.Invalidate(); } //} } catch { MainForm.Instance.faTabStrip1.Items[itemNumber].ItemIcon = Resources.blank; MainForm.Instance.faTabStrip1.Items[itemNumber].BrowserIsLoading = false; MainForm.Instance.faTabStrip1.Invalidate(); } } } else if (itemNumber == -1) // 的时候,则为下载图片 { WriteBytesToFile(filename, image.GetAsPng(1f, true, out imageW, out imageH).ToArray()); } else if (itemNumber == -2) //下载验证码 { if (image == null) { return; } } }