为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

将图片转换成HTML格式的文字图程序源代码

2017-10-13 4页 doc 16KB 17阅读

用户头像

is_482581

暂无简介

举报
将图片转换成HTML格式的文字图程序源代码将图片转换成HTML格式的文字图程序源代码 ————————————————以下为程序代码————————————— using System; using System.Drawing; using System.Text; namespace Blood.Com.ClassLib { /// /// 将图片转换为Html /// public class Picture2HtmlPicture { /// /// 构造函数 /// public Picture2HtmlPictu...
将图片转换成HTML格式的文字图程序源代码
将图片转换成HTML格式的文字图程序源代码 ————————————————以下为程序代码————————————— using System; using System.Drawing; using System.Text; namespace Blood.Com.ClassLib { /// /// 将图片转换为Html /// public class Picture2HtmlPicture { /// /// 构造函数 /// public Picture2HtmlPicture() { //构造函数 } /// /// 将图片转换为HTML /// /// 图片文件名 /// HTML内容 public string MakeHtmlPicture(string FileName) { try { int intX; int intY; int intWidth; Color clrPicture; Bitmap bmpPicture; StringBuilder sb = new StringBuilder(); //检测文件名是否为空,如果为空,则返回空 if (FileName == "") { return null; } //打开图片文件 bmpPicture = new Bitmap(FileName); sb.Append("\r\n"); sb.Append("\r\n"); sb.Append("\r\n"); intWidth = bmpPicture.Size.Width; if (intWidth < 100) { intWidth = 100; } else { intWidth = bmpPicture.Size.Width + 50; } sb.Append("\r\n"); //通过循环,将图片的颜色提取出来 for (intY = 0; intY < bmpPicture.Size.Height; intY++) { for (intX = 0; intX < bmpPicture.Size.Width; intX++) { clrPicture = bmpPicture.GetPixel(intX,intY); string strColor = clrPicture.ToArgb().ToString("x5"); string strHexColor = "#" + strColor.Substring(2); //将图片颜色写到HTML中 sb.Append(""); sb.Append("x"); sb.Append(""); sb.Append("\r\n"); } sb.Append("
\r\n"); } sb.Append("
\r\n"); sb.Append("\r\n"); sb.Append(""); //返回HTML内容 return sb.ToString(); } catch(Exception err) { throw(new Exception("发生异常:" + err.Message)); } } } } ———————————————————————————————————— private void button1_Click(object sender, System.EventArgs e) { ofdPicture.ShowDialog(); string strFileName = ofdPicture.FileName; Picture2HtmlPicture clsHtmlPicture = new Picture2HtmlPicture(); txtTest.Text = clsHtmlPicture.MakeHtmlPicture(strFileName); }
/
本文档为【将图片转换成HTML格式的文字图程序源代码】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索