怎样将一个图像传递给Memorystream
以下代码是将网页上的图片保存到剪切板再保存到bincode,能否不经过Clipboard,将IMG传递给bincode,代码应该怎么写?
HTMLDocument html = (HTMLDocument)obj.Document.DomDocument;
HTMLBody body = (HTMLBody)html.body;
IHTMLControlRange range = (IHTMLControlRange)body.createControlRange();
IHTMLControlElement IMG;
for (int i = 0; i < obj.Document.Images.Count; i++)
{
IHTMLImgElement img = (IHTMLImgElement)obj.Document.Images[i].DomElement;
if (img.src.IndexOf("Img=") >= 0)
{
IMG = (IHTMLControlElement)obj.Document.Images[i].DomElement;
range.add(IMG);
while (Clipboard.ContainsImage())
Application.DoEvents();
range.execCommand("Copy", false, null);
img = null;
IMG = null;
if (Clipboard.ContainsImage())
{
MemoryStream bincode = new MemoryStream();
Clipboard.GetImage().Save(bincode, System.Drawing.Imaging.ImageFormat.Bmp);
}
break;
}
}