国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#在圖片增加文字的實現代碼

2019-10-29 21:09:24
字體:
來源:轉載
供稿:網友

業務需要動態給圖片增加文字(書本的封面圖片),修改字體大小、字體、顏色、控制位置

測試代碼:

string path = @"E:/cover.png";      Bitmap bmp = new Bitmap(path);      Graphics g = Graphics.FromImage(bmp);      String str = "賢愚經";      Font font = new Font("仿宋_GB2312", 14, FontStyle.Bold);//設置字體,大小,粗細      SolidBrush sbrush = new SolidBrush(Color.White);//設置顏色      int base_left = 10;      int left_space = 30;      int base_top = 27;      int top_space = 27;      for (int i = 0; i < str.Length; i++)      {        if (i > 13)        {          continue;          g.DrawString(str[i] + "", font, sbrush, new PointF(base_left + (left_space * 2), base_top + (top_space * (i - 14))));        }        else if (i > 6)        {          g.DrawString(str[i] + "", font, sbrush, new PointF(base_left + (left_space * 1), base_top + (top_space * (i - 7))));        }        else        {          g.DrawString(str[i] + "", font, sbrush, new PointF(base_left, base_top + (top_space * i)));        }      }      //MemoryStream ms = new MemoryStream();      //bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);      bmp.Save(@"E:/cover1.png");

字體選擇:

黑體:SimHei
宋體:SimSun
新宋體:NSimSun
仿宋:FangSong
楷體:KaiTi
仿宋_GB2312:FangSong_GB2312
楷體_GB2312:KaiTi_GB2312
微軟雅黑體:Microsoft YaHei

以上所述是小編給大家介紹的C#在圖片增加文字的實現代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對VEVB武林網網站的支持!


注:相關教程知識閱讀請移步到c#教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 太湖县| 霍邱县| 固安县| 保山市| 沧源| 昌都县| 双江| 五莲县| 太原市| 南部县| 宜兰县| 崇仁县| 米林县| 潜山县| 临湘市| 灵武市| 和顺县| 广河县| 宁武县| 兰溪市| 鄄城县| 长丰县| 夏邑县| 襄城县| 承德市| 晋江市| 大石桥市| 惠水县| 和静县| 德江县| 彭州市| 若羌县| 祁东县| 建阳市| 嘉兴市| 宜兰县| 东明县| 大渡口区| 杭锦旗| 祁东县| 施甸县|