System.Drawing.Image img = GetRegCodePic(webBrowser1, "", "/TCRM/image.jsp", "");
int width = img.Width * 4;
int height = img.Height * 4;
System.Drawing.Image imgFlax = new System.Drawing.Bitmap(width, height);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(imgFlax);
g.DrawImage(img, new Rectangle(0, 0, width - 1, height - 1));
imgFlax.Save("bmptxt.tif", ImageFormat.Tiff);
img.Dispose();
imgFlax.Dispose();
MODI.Document md = new MODI.Document();
// The Create method grabs the picture from
// disk snd prepares for OCR.
md.Create("bmptxt.tif");
// Do the OCR.
md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
// This string will contain the text.
// Get the first (and only image)
MODI.Image image = (MODI.Image)md.Images[0];
// Get the layout.
MODI.Layout layout = image.Layout;
// Loop through the words.
for (int j = 0; j < layout.Words.Count; j++)
{
// Get this word.
MODI.Word word = (MODI.Word)layout.Words[j];
// Add a blank space to separate words.
if (strText.Length > 0)
{
strText += " ";
}
// Add the word.
strText += word.Text;
}
// Close the MODI.Document object.
public static int GetPicIndex(WebBrowser wbMail, string Src, string Alt)
{
int imgnum = -1;
for (int i = 0; i < wbMail.Document.Images.Count; i++) //获取所有的Image元素
{
IHTMLImgElement img = (IHTMLImgElement)wbMail.Document.Images[i].DomElement;
if (Alt == "")
{
if (img.src.Contains(Src)) return i;
}
else
{
if (!string.IsNullOrEmpty(img.alt))
{
if (img.alt.Contains(Alt)) return i;
}
}
}
return imgnum;
}